@dripfi/drip-sdk 1.4.34 → 1.4.35-beta.2

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.
Files changed (150) hide show
  1. package/package.json +11 -12
  2. package/dist/PerqApi.d.ts +0 -49
  3. package/dist/PerqApi.js +0 -475
  4. package/dist/PerqSdk.d.ts +0 -40
  5. package/dist/PerqSdk.js +0 -75
  6. package/dist/abi/ERC20.json +0 -222
  7. package/dist/abi/SlotBurnTokenAbi.json +0 -130
  8. package/dist/abi/WethTokenAbi.json +0 -25
  9. package/dist/abi/index.d.ts +0 -411
  10. package/dist/abi/index.js +0 -23
  11. package/dist/abi/perq/BridgeMainnetPerqToSonicAbi.json +0 -598
  12. package/dist/abi/perq/BridgeSonicPerqToMainnetAbi.json +0 -733
  13. package/dist/abi/perq/PerqSwapAndRecyclerAbi.json +0 -95
  14. package/dist/abi/perq/PerqTokenAbi.json +0 -48
  15. package/dist/abi/perq/PerqVestingAbi.json +0 -126
  16. package/dist/abi/perq/TokenRecyclerAbi.json +0 -41
  17. package/dist/constants.d.ts +0 -2
  18. package/dist/constants.js +0 -5
  19. package/dist/contracts/BaseContract.d.ts +0 -7
  20. package/dist/contracts/BaseContract.js +0 -16
  21. package/dist/contracts/BridgeMainnetPerqToSonicContract.d.ts +0 -9
  22. package/dist/contracts/BridgeMainnetPerqToSonicContract.js +0 -48
  23. package/dist/contracts/BridgeSonicPerqToMainnetContract.d.ts +0 -9
  24. package/dist/contracts/BridgeSonicPerqToMainnetContract.js +0 -47
  25. package/dist/contracts/ERC20TokenContract.d.ts +0 -10
  26. package/dist/contracts/ERC20TokenContract.js +0 -34
  27. package/dist/contracts/SlotBurnTokenContract.d.ts +0 -8
  28. package/dist/contracts/SlotBurnTokenContract.js +0 -26
  29. package/dist/contracts/index.d.ts +0 -9
  30. package/dist/contracts/index.js +0 -22
  31. package/dist/contracts/perq/PerqSwapAndRecyclerContract.d.ts +0 -8
  32. package/dist/contracts/perq/PerqSwapAndRecyclerContract.js +0 -28
  33. package/dist/contracts/perq/PerqTokenContract.d.ts +0 -7
  34. package/dist/contracts/perq/PerqTokenContract.js +0 -26
  35. package/dist/contracts/perq/PerqTokenRecyclerContract.d.ts +0 -7
  36. package/dist/contracts/perq/PerqTokenRecyclerContract.js +0 -20
  37. package/dist/contracts/perq/PerqVestingContract.d.ts +0 -13
  38. package/dist/contracts/perq/PerqVestingContract.js +0 -56
  39. package/dist/index.d.ts +0 -5
  40. package/dist/index.js +0 -28
  41. package/dist/subpackages/BridgePerqPackage.d.ts +0 -36
  42. package/dist/subpackages/BridgePerqPackage.js +0 -205
  43. package/dist/subpackages/LitePackage.d.ts +0 -19
  44. package/dist/subpackages/LitePackage.js +0 -106
  45. package/dist/subpackages/LoyaltyCardsPackage.d.ts +0 -21
  46. package/dist/subpackages/LoyaltyCardsPackage.js +0 -123
  47. package/dist/subpackages/PoolsPackage.d.ts +0 -21
  48. package/dist/subpackages/PoolsPackage.js +0 -58
  49. package/dist/subpackages/RecyclerPackage.d.ts +0 -13
  50. package/dist/subpackages/RecyclerPackage.js +0 -87
  51. package/dist/subpackages/SignHandlerPackage.d.ts +0 -8
  52. package/dist/subpackages/SignHandlerPackage.js +0 -33
  53. package/dist/subpackages/SiloPackage.d.ts +0 -18
  54. package/dist/subpackages/SiloPackage.js +0 -112
  55. package/dist/subpackages/SiloVaultOperations.d.ts +0 -31
  56. package/dist/subpackages/SiloVaultOperations.js +0 -119
  57. package/dist/subpackages/TokenUtilsPackage.d.ts +0 -27
  58. package/dist/subpackages/TokenUtilsPackage.js +0 -93
  59. package/dist/subpackages/UserPackage.d.ts +0 -11
  60. package/dist/subpackages/UserPackage.js +0 -43
  61. package/dist/subpackages/VaultHandlerPackage.d.ts +0 -54
  62. package/dist/subpackages/VaultHandlerPackage.js +0 -107
  63. package/dist/subpackages/VestingPackage.d.ts +0 -14
  64. package/dist/subpackages/VestingPackage.js +0 -112
  65. package/dist/subpackages/YelayVaultOperations.d.ts +0 -13
  66. package/dist/subpackages/YelayVaultOperations.js +0 -107
  67. package/dist/types/Asset.d.ts +0 -5
  68. package/dist/types/Asset.js +0 -2
  69. package/dist/types/BeanEntry.d.ts +0 -12
  70. package/dist/types/BeanEntry.js +0 -2
  71. package/dist/types/BeansBalance.d.ts +0 -5
  72. package/dist/types/BeansBalance.js +0 -2
  73. package/dist/types/BridgePerq.d.ts +0 -14
  74. package/dist/types/BridgePerq.js +0 -2
  75. package/dist/types/ChainId.d.ts +0 -7
  76. package/dist/types/ChainId.js +0 -9
  77. package/dist/types/ClaimSpecialEditionLoyaltyCardPayload.d.ts +0 -4
  78. package/dist/types/ClaimSpecialEditionLoyaltyCardPayload.js +0 -2
  79. package/dist/types/DeployedProject.d.ts +0 -55
  80. package/dist/types/DeployedProject.js +0 -2
  81. package/dist/types/DeployedVault.d.ts +0 -14
  82. package/dist/types/DeployedVault.js +0 -2
  83. package/dist/types/DepositToken.d.ts +0 -8
  84. package/dist/types/DepositToken.js +0 -2
  85. package/dist/types/DetailedProjectData.d.ts +0 -34
  86. package/dist/types/DetailedProjectData.js +0 -2
  87. package/dist/types/DistributionToken.d.ts +0 -6
  88. package/dist/types/DistributionToken.js +0 -2
  89. package/dist/types/ELoyaltyCardTier.d.ts +0 -10
  90. package/dist/types/ELoyaltyCardTier.js +0 -13
  91. package/dist/types/Earnings.d.ts +0 -11
  92. package/dist/types/Earnings.js +0 -2
  93. package/dist/types/LinkWalletPayload.d.ts +0 -9
  94. package/dist/types/LinkWalletPayload.js +0 -2
  95. package/dist/types/LinkedPodWallets.d.ts +0 -6
  96. package/dist/types/LinkedPodWallets.js +0 -2
  97. package/dist/types/LoyaltyCard.d.ts +0 -11
  98. package/dist/types/LoyaltyCard.js +0 -2
  99. package/dist/types/MigrationOption.d.ts +0 -6
  100. package/dist/types/MigrationOption.js +0 -2
  101. package/dist/types/MyPerqData.d.ts +0 -19
  102. package/dist/types/MyPerqData.js +0 -2
  103. package/dist/types/NFTBoost.d.ts +0 -10
  104. package/dist/types/NFTBoost.js +0 -2
  105. package/dist/types/OverallStats.d.ts +0 -7
  106. package/dist/types/OverallStats.js +0 -2
  107. package/dist/types/PerqConfig.d.ts +0 -18
  108. package/dist/types/PerqConfig.js +0 -37
  109. package/dist/types/PerqToBeansSwapInfo.d.ts +0 -8
  110. package/dist/types/PerqToBeansSwapInfo.js +0 -2
  111. package/dist/types/ProjectHistoricalTvl.d.ts +0 -4
  112. package/dist/types/ProjectHistoricalTvl.js +0 -2
  113. package/dist/types/QLFastRedeem.d.ts +0 -16
  114. package/dist/types/QLFastRedeem.js +0 -2
  115. package/dist/types/ReducedProjectData.d.ts +0 -21
  116. package/dist/types/ReducedProjectData.js +0 -2
  117. package/dist/types/SdkType.d.ts +0 -2
  118. package/dist/types/SdkType.js +0 -2
  119. package/dist/types/SignedPayload.d.ts +0 -12
  120. package/dist/types/SignedPayload.js +0 -2
  121. package/dist/types/SlotMachineSpinCost.d.ts +0 -7
  122. package/dist/types/SlotMachineSpinCost.js +0 -2
  123. package/dist/types/SpecialEditionLoyaltyCard.d.ts +0 -9
  124. package/dist/types/SpecialEditionLoyaltyCard.js +0 -2
  125. package/dist/types/Strategy.d.ts +0 -9
  126. package/dist/types/Strategy.js +0 -2
  127. package/dist/types/StretchGoal.d.ts +0 -5
  128. package/dist/types/StretchGoal.js +0 -2
  129. package/dist/types/SwapInfo.d.ts +0 -6
  130. package/dist/types/SwapInfo.js +0 -2
  131. package/dist/types/UpgradeLoyaltyCardPayload.d.ts +0 -4
  132. package/dist/types/UpgradeLoyaltyCardPayload.js +0 -2
  133. package/dist/types/UserRewards.d.ts +0 -6
  134. package/dist/types/UserRewards.js +0 -2
  135. package/dist/types/VaultData.d.ts +0 -32
  136. package/dist/types/VaultData.js +0 -2
  137. package/dist/types/VaultOperationParams.d.ts +0 -12
  138. package/dist/types/VaultOperationParams.js +0 -2
  139. package/dist/types/VaultReward.d.ts +0 -16
  140. package/dist/types/VaultReward.js +0 -4
  141. package/dist/types/VaultStats.d.ts +0 -6
  142. package/dist/types/VaultStats.js +0 -2
  143. package/dist/types/VaultType.d.ts +0 -3
  144. package/dist/types/VaultType.js +0 -4
  145. package/dist/types/VestingInfo.d.ts +0 -8
  146. package/dist/types/VestingInfo.js +0 -2
  147. package/dist/types/YelayVersion.d.ts +0 -2
  148. package/dist/types/YelayVersion.js +0 -2
  149. package/dist/types/index.d.ts +0 -34
  150. package/dist/types/index.js +0 -8
@@ -1,21 +0,0 @@
1
- import PerqSdk from '../PerqSdk';
2
- import { DetailedProjectData, MyPerqData, ReducedProjectData, UserRewards, VaultData, VaultStats } from '../types';
3
- import OverallStats from '../types/OverallStats';
4
- export default class PoolsPackage {
5
- private perqSdk;
6
- constructor(perqSdk: PerqSdk);
7
- getUserPoolBalance(vaultAddress: string, onChainProjectId: number): Promise<string>;
8
- getAllPools(): Promise<VaultData[]>;
9
- getMyPerqBalance(): Promise<MyPerqData[]>;
10
- getPoolDetails(vaultAddress: string, onChainProjectId: number): Promise<VaultData>;
11
- getAllProjects(): Promise<ReducedProjectData[]>;
12
- getProjectDetails(projectName: string): Promise<DetailedProjectData>;
13
- getOverallStats(): Promise<OverallStats>;
14
- /**
15
- * @deprecated Use `getOverallStats()` instead.
16
- */
17
- getPoolStats(): Promise<VaultStats>;
18
- getRewardsPerHour(vaultAddress: string): Promise<number>;
19
- getUserBoostedNfts(vaultAddress: string): Promise<string[]>;
20
- getRewards(): Promise<UserRewards>;
21
- }
@@ -1,58 +0,0 @@
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 getOverallStats() {
36
- return this.perqSdk.perqApi.fetchOverallStats();
37
- }
38
- /**
39
- * @deprecated Use `getOverallStats()` instead.
40
- */
41
- async getPoolStats() {
42
- return this.perqSdk.perqApi.fetchPoolStats();
43
- }
44
- async getRewardsPerHour(vaultAddress) {
45
- const userAddress = await this.perqSdk.signer.getAddress();
46
- return this.perqSdk.perqApi.fetchRewardsPerHour(userAddress, vaultAddress);
47
- }
48
- async getUserBoostedNfts(vaultAddress) {
49
- const userAddress = await this.perqSdk.signer.getAddress();
50
- return this.perqSdk.perqApi.getUserBoostedNfts(userAddress, vaultAddress);
51
- }
52
- async getRewards() {
53
- const userAddress = await this.perqSdk.signer.getAddress();
54
- const userRewards = this.perqSdk.perqApi.fetchUserRewards(userAddress);
55
- return userRewards;
56
- }
57
- }
58
- exports.default = PoolsPackage;
@@ -1,13 +0,0 @@
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
- }
@@ -1,87 +0,0 @@
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
- class RecyclerPackage {
9
- perqSdk;
10
- constructor(perqSdk) {
11
- this.perqSdk = perqSdk;
12
- }
13
- async getTokenAllowanceForRecycler(tokenAddress) {
14
- if (!this.perqSdk.signer) {
15
- throw Error('No signer provided');
16
- }
17
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
18
- const allowance = await tokenContract.getAllowance(await this.perqSdk.signer.getAddress(), this.perqSdk.perqTokenRecyclerContract.getContractAddress());
19
- return allowance;
20
- }
21
- async getTokenAllowanceForSwapAndRecycler(tokenAddress) {
22
- if (!this.perqSdk.signer) {
23
- throw Error('No signer provided');
24
- }
25
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
26
- const allowance = await tokenContract.getAllowance(await this.perqSdk.signer.getAddress(), this.perqSdk.perqSwapAndRecyclerContract.getContractAddress());
27
- return allowance;
28
- }
29
- async recycleTokens(tokenAddress = this.perqSdk.perqConfig.perqTokenAddress, amountToRecycle, beneficiary = ethers_1.ethers.constants.AddressZero, price, deadline, signature) {
30
- if (this.perqSdk.perqConfig.perqTokenRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
31
- throw Error('Recycler contract address not defined');
32
- }
33
- if (!this.perqSdk.signer) {
34
- throw Error('No signer provided');
35
- }
36
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
37
- const decimals = await tokenContract.getPrecission();
38
- const amountWithDecimals = ethers_1.ethers.utils.parseUnits(amountToRecycle, decimals).toString();
39
- const recycleTx = await this.perqSdk.perqTokenRecyclerContract.recycle(amountWithDecimals, beneficiary, price, deadline, signature);
40
- const receipt = await recycleTx.wait();
41
- return receipt.transactionHash;
42
- }
43
- async swapAndRecycleETH(beneficiary, path, minAmountOutWithDecimals, amountOfEth, price, deadline, signature) {
44
- if (this.perqSdk.perqConfig.perqSwapAndRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
45
- throw Error('Recycler contract address not defined');
46
- }
47
- const swapAndRecycleTx = await this.perqSdk.perqSwapAndRecyclerContract.swapETHAndRecycle(beneficiary, path, minAmountOutWithDecimals, amountOfEth, price, deadline, signature);
48
- const receipt = await swapAndRecycleTx.wait();
49
- return receipt.transactionHash;
50
- }
51
- async swapAndRecycleERC20(beneficiary, path, minAmountOutWithDecimals, amountInWithDecimals, price, deadline, signature) {
52
- if (this.perqSdk.perqConfig.perqSwapAndRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
53
- throw Error('Recycler contract address not defined');
54
- }
55
- const swapAndRecycleTx = await this.perqSdk.perqSwapAndRecyclerContract.swapAndRecycle(beneficiary, path, amountInWithDecimals, minAmountOutWithDecimals, price, deadline, signature);
56
- const receipt = await swapAndRecycleTx.wait();
57
- return receipt.transactionHash;
58
- }
59
- async approveTokenForRecycler(tokenAddress, amount) {
60
- if (!this.perqSdk.signer) {
61
- throw Error('No signer provided');
62
- }
63
- if (this.perqSdk.perqConfig.perqTokenRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
64
- throw Error('Recycler contract address not defined');
65
- }
66
- if (!this.perqSdk.signer) {
67
- throw Error('No signer provided');
68
- }
69
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
70
- const decimals = await tokenContract.getPrecission();
71
- const parsedAmount = ethers_1.ethers.utils.parseUnits(amount, decimals);
72
- return await tokenContract.approveToken(this.perqSdk.perqConfig.perqTokenRecyclerAddress, parsedAmount);
73
- }
74
- async approveTokenForSwapAndRecycler(tokenAddress, amount) {
75
- if (!this.perqSdk.signer) {
76
- throw Error('No signer provided');
77
- }
78
- if (this.perqSdk.perqConfig.perqSwapAndRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
79
- throw Error('Recycler contract address not defined');
80
- }
81
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
82
- const decimals = await tokenContract.getPrecission();
83
- const parsedAmount = ethers_1.ethers.utils.parseUnits(amount, decimals);
84
- return await tokenContract.approveToken(this.perqSdk.perqConfig.perqSwapAndRecyclerAddress, parsedAmount);
85
- }
86
- }
87
- exports.default = RecyclerPackage;
@@ -1,8 +0,0 @@
1
- import PerqSdk from '../PerqSdk';
2
- import { NonceEnrichedSignedPayload } from '../types';
3
- export default class SignHandlerPackage {
4
- private perqSdk;
5
- constructor(perqSdk: PerqSdk);
6
- private getEnrichedPayload;
7
- signPayload<T>(payload: T): Promise<NonceEnrichedSignedPayload<T>>;
8
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class SignHandlerPackage {
4
- perqSdk;
5
- constructor(perqSdk) {
6
- this.perqSdk = perqSdk;
7
- }
8
- async getEnrichedPayload(payload) {
9
- return this.perqSdk.perqApi.getNonceEnrichedPayload(payload.payload);
10
- }
11
- async signPayload(payload) {
12
- if (!this.perqSdk.signer) {
13
- throw new Error('No signer provided');
14
- }
15
- // Wrap the payload in a Basepayload to enrich it later on
16
- const basePayload = {
17
- payload,
18
- };
19
- const signerAddress = await this.perqSdk.signer.getAddress();
20
- // Get enriched payload with nonce before signing
21
- const enrichedPayload = await this.getEnrichedPayload(basePayload);
22
- // Create message to sign
23
- const message = JSON.stringify(enrichedPayload);
24
- // Sign the message
25
- const signature = await this.perqSdk.signer.signMessage(message);
26
- return {
27
- signature,
28
- signerAddress,
29
- payload: enrichedPayload,
30
- };
31
- }
32
- }
33
- exports.default = SignHandlerPackage;
@@ -1,18 +0,0 @@
1
- import { BigNumber, Signer } from 'ethers';
2
- import { SiloSdk } from '@dripfi/silo-sdk';
3
- export default class SiloPackage {
4
- siloSdk: SiloSdk;
5
- constructor(signer: Signer);
6
- deposit(assetAmount: string, vaultAddress: string): Promise<string | undefined>;
7
- withdraw(assetAmount: string, vaultAddress: string): Promise<string | undefined>;
8
- redeem(sharesAmount: string, vaultAddress: string): Promise<string | undefined>;
9
- getHistoricalTvl(): Promise<any>;
10
- getApy(): Promise<any>;
11
- getEarnedRewards(): Promise<any>;
12
- getBalanceInShares(vaultAddress: string): Promise<BigNumber>;
13
- getBalanceInAssets(vaultAddress: string): Promise<BigNumber>;
14
- getTotalSupply(vaultAddress: string): Promise<BigNumber>;
15
- getTotalAssets(vaultAddress: string): Promise<BigNumber>;
16
- private convertToShares;
17
- private convertToAssets;
18
- }
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const silo_sdk_1 = require("@dripfi/silo-sdk");
4
- class SiloPackage {
5
- siloSdk;
6
- constructor(signer) {
7
- this.siloSdk = new silo_sdk_1.SiloSdk(signer);
8
- }
9
- async deposit(assetAmount, vaultAddress) {
10
- try {
11
- const tx = await this.siloSdk.contracts.deposit(assetAmount, vaultAddress);
12
- return tx;
13
- }
14
- catch (error) {
15
- console.error('Error depositing:', error);
16
- throw error;
17
- }
18
- }
19
- async withdraw(assetAmount, vaultAddress) {
20
- try {
21
- const tx = await this.siloSdk.contracts.withdraw(assetAmount, vaultAddress);
22
- return tx;
23
- }
24
- catch (error) {
25
- console.error('Error depositing:', error);
26
- throw error;
27
- }
28
- }
29
- async redeem(sharesAmount, vaultAddress) {
30
- try {
31
- const tx = await this.siloSdk.contracts.redeem(sharesAmount, vaultAddress);
32
- return tx;
33
- }
34
- catch (error) {
35
- console.error('Error depositing:', error);
36
- throw error;
37
- }
38
- }
39
- async getHistoricalTvl() {
40
- console.log('getHistoricalTvl to be implemented');
41
- return await this.siloSdk.getHistoricalTvl();
42
- }
43
- async getApy() {
44
- console.log('getApy to be implemented');
45
- return await this.siloSdk.getApy();
46
- }
47
- async getEarnedRewards() {
48
- console.log('getEarnedRewards to be implemented');
49
- return await this.siloSdk.getEarnedRewards();
50
- }
51
- async getBalanceInShares(vaultAddress) {
52
- try {
53
- const balance = await this.siloSdk.contracts.getBalance(vaultAddress);
54
- return balance;
55
- }
56
- catch (error) {
57
- console.error('Error getting balance:', error);
58
- throw error;
59
- }
60
- }
61
- async getBalanceInAssets(vaultAddress) {
62
- try {
63
- const balance = await this.siloSdk.contracts.getBalanceInAssets(vaultAddress);
64
- return balance;
65
- }
66
- catch (error) {
67
- console.error('Error getting balance:', error);
68
- throw error;
69
- }
70
- }
71
- async getTotalSupply(vaultAddress) {
72
- try {
73
- const totalSupply = await this.siloSdk.contracts.getTotalSupply(vaultAddress);
74
- return totalSupply;
75
- }
76
- catch (error) {
77
- console.error('Error getting totalSupply:', error);
78
- throw error;
79
- }
80
- }
81
- async getTotalAssets(vaultAddress) {
82
- try {
83
- const totalAssets = await this.siloSdk.contracts.getTotalAssets(vaultAddress);
84
- return totalAssets;
85
- }
86
- catch (error) {
87
- console.error('Error getting totalAssets:', error);
88
- throw error;
89
- }
90
- }
91
- async convertToShares(assetsAmount, vaultAddress) {
92
- try {
93
- const shares = await this.siloSdk.contracts.convertToShares(assetsAmount, vaultAddress);
94
- return shares;
95
- }
96
- catch (error) {
97
- console.error('Error converting to shares:', error);
98
- throw error;
99
- }
100
- }
101
- async convertToAssets(sharesAmount, vaultAddress) {
102
- try {
103
- const assets = await this.siloSdk.contracts.convertToAssets(sharesAmount, vaultAddress);
104
- return assets;
105
- }
106
- catch (error) {
107
- console.error('Error converting to assets:', error);
108
- throw error;
109
- }
110
- }
111
- }
112
- exports.default = SiloPackage;
@@ -1,31 +0,0 @@
1
- import PerqSdk from '../PerqSdk';
2
- import { VaultOperationParams } from '../types/VaultOperationParams';
3
- import { VaultOperations, WithdrawParams } from './VaultHandlerPackage';
4
- /**
5
- * Silo SDK vault operations implementation
6
- */
7
- export declare class SiloVaultOperations implements VaultOperations {
8
- private perqSdk;
9
- constructor(perqSdk: PerqSdk);
10
- getAllowance(params: VaultOperationParams): Promise<boolean>;
11
- approveAllowance(params: VaultOperationParams): Promise<string>;
12
- deposit(params: VaultOperationParams): Promise<string>;
13
- withdraw(params: WithdrawParams): Promise<string>;
14
- getBalance(vaultAddress: string, tokenAddress: string): Promise<string>;
15
- /**
16
- * Handles Silo withdraw with automatic full/partial withdraw detection
17
- */
18
- private handleSiloWithdraw;
19
- /**
20
- * Handles a full withdraw from a Silo vault
21
- */
22
- private handleSiloFullWithdraw;
23
- /**
24
- * Handles a partial withdraw from a Silo vault
25
- */
26
- private handleSiloPartialWithdraw;
27
- /**
28
- * Extracts transaction hash from various transaction response formats
29
- */
30
- private extractTransactionHash;
31
- }
@@ -1,119 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SiloVaultOperations = void 0;
4
- const ethers_1 = require("ethers");
5
- /**
6
- * Silo SDK vault operations implementation
7
- */
8
- class SiloVaultOperations {
9
- perqSdk;
10
- constructor(perqSdk) {
11
- this.perqSdk = perqSdk;
12
- }
13
- async getAllowance(params) {
14
- const { sourceTokenAddress, vaultAddress, amount } = params;
15
- if (!this.perqSdk.siloPackage) {
16
- throw new Error('Silo package not initialized. Please provide a signer.');
17
- }
18
- try {
19
- // For Silo, we use the standard ERC20 allowance
20
- const allowance = await this.perqSdk.tokenUtils.getERC20TokenAllowance(vaultAddress, sourceTokenAddress);
21
- // Get required amount with correct decimals
22
- const requiredAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
23
- return allowance.gte(requiredAmount);
24
- }
25
- catch (error) {
26
- console.error('Error checking allowance:', error);
27
- return false;
28
- }
29
- }
30
- async approveAllowance(params) {
31
- const { sourceTokenAddress, vaultAddress, amount } = params;
32
- if (!this.perqSdk.siloPackage) {
33
- throw new Error('Silo package not initialized. Please provide a signer.');
34
- }
35
- // For Silo, we use the standard ERC20 approval
36
- return await this.perqSdk.tokenUtils.approveAllowance(sourceTokenAddress, amount, vaultAddress);
37
- }
38
- async deposit(params) {
39
- const { amount, vaultAddress, sourceTokenAddress } = params;
40
- if (!this.perqSdk.siloPackage) {
41
- throw new Error('Silo package not initialized. Please provide a signer.');
42
- }
43
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
44
- const tx = await this.perqSdk.siloPackage.deposit(parsedAmount.toString(), vaultAddress);
45
- return this.extractTransactionHash(tx);
46
- }
47
- async withdraw(params) {
48
- const { amount, vaultAddress, tokenAddress } = params;
49
- if (!this.perqSdk.siloPackage) {
50
- throw new Error('Silo package not initialized. Please provide a signer.');
51
- }
52
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, tokenAddress);
53
- return await this.handleSiloWithdraw(tokenAddress, vaultAddress, parsedAmount.toString());
54
- }
55
- async getBalance(vaultAddress, tokenAddress) {
56
- if (!this.perqSdk.signer) {
57
- throw new Error('Signer not initialized');
58
- }
59
- const balance = await this.perqSdk.siloPackage.getBalanceInAssets(vaultAddress);
60
- const formattedBalance = await this.perqSdk.tokenUtils.formatAmountWithDecimals(balance, tokenAddress);
61
- return formattedBalance;
62
- }
63
- /**
64
- * Handles Silo withdraw with automatic full/partial withdraw detection
65
- */
66
- async handleSiloWithdraw(tokenAddress, vaultAddress, amount) {
67
- let userBalance = ethers_1.BigNumber.from(0);
68
- try {
69
- userBalance = await this.perqSdk.siloPackage.getBalanceInAssets(vaultAddress);
70
- }
71
- catch (error) {
72
- console.error('Error getting user balance for silo withdraw: ', error);
73
- }
74
- const withdrawAmount = ethers_1.BigNumber.from(amount);
75
- try {
76
- if (withdrawAmount.gte(userBalance)) {
77
- return await this.handleSiloFullWithdraw(vaultAddress);
78
- }
79
- else {
80
- return await this.handleSiloPartialWithdraw(vaultAddress, withdrawAmount);
81
- }
82
- }
83
- catch (error) {
84
- console.error('Error handling silo withdraw: ', error);
85
- throw error;
86
- }
87
- }
88
- /**
89
- * Handles a full withdraw from a Silo vault
90
- */
91
- async handleSiloFullWithdraw(vaultAddress) {
92
- const balanceInShares = await this.perqSdk.siloPackage.getBalanceInShares(vaultAddress);
93
- const tx = await this.perqSdk.siloPackage.redeem(balanceInShares.toString(), vaultAddress);
94
- return this.extractTransactionHash(tx);
95
- }
96
- /**
97
- * Handles a partial withdraw from a Silo vault
98
- */
99
- async handleSiloPartialWithdraw(vaultAddress, parsedWithdrawAmount) {
100
- const tx = await this.perqSdk.siloPackage.withdraw(parsedWithdrawAmount.toString(), vaultAddress);
101
- return this.extractTransactionHash(tx);
102
- }
103
- /**
104
- * Extracts transaction hash from various transaction response formats
105
- */
106
- extractTransactionHash(tx) {
107
- if (typeof tx === 'string') {
108
- return tx;
109
- }
110
- if (tx?.hash) {
111
- return tx.hash;
112
- }
113
- if (tx?.transactionHash) {
114
- return tx.transactionHash;
115
- }
116
- throw new Error('Unable to extract transaction hash from response');
117
- }
118
- }
119
- exports.SiloVaultOperations = SiloVaultOperations;
@@ -1,27 +0,0 @@
1
- import { BigNumber } from 'ethers';
2
- import PerqSdk from '../PerqSdk';
3
- export default class TokenUtilsPackage {
4
- private perqSdk;
5
- constructor(perqSdk: PerqSdk);
6
- /**
7
- * Helper method to parse amount with correct token decimals
8
- * @param amount - The amount as a string
9
- * @param tokenAddress - The token contract address
10
- * @returns Promise<BigNumber> - The parsed amount with correct decimals
11
- */
12
- parseAmountWithDecimals(amount: string, tokenAddress: string): Promise<BigNumber>;
13
- /**
14
- * Helper method to format amount from token decimals to human-readable string
15
- * @param amount - The amount as BigNumber with token decimals
16
- * @param tokenAddress - The token contract address
17
- * @returns Promise<string> - The formatted amount as human-readable string
18
- */
19
- formatAmountWithDecimals(amount: BigNumber, tokenAddress: string): Promise<string>;
20
- getTokenPrice(tokenName: string): Promise<number>;
21
- getAllowance(tokenAddress: string, spender: string): Promise<string>;
22
- approveAllowance(tokenAddress: string, amount: string, spenderAddress: string): Promise<string>;
23
- transferErc20Token(tokenAddress: string, amount: string, receiver: string): Promise<string>;
24
- wrapEther(amount: string, tokenAddress: string): Promise<string>;
25
- getERC20TokenAllowance(spender: string, tokenAddress: string): Promise<BigNumber>;
26
- getPerqTokenContractAddress(): string;
27
- }
@@ -1,93 +0,0 @@
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 WethTokenAbi_json_1 = __importDefault(require("../abi/WethTokenAbi.json"));
9
- class TokenUtilsPackage {
10
- perqSdk;
11
- constructor(perqSdk) {
12
- this.perqSdk = perqSdk;
13
- }
14
- /**
15
- * Helper method to parse amount with correct token decimals
16
- * @param amount - The amount as a string
17
- * @param tokenAddress - The token contract address
18
- * @returns Promise<BigNumber> - The parsed amount with correct decimals
19
- */
20
- async parseAmountWithDecimals(amount, tokenAddress) {
21
- if (!this.perqSdk.signer) {
22
- throw new Error('No signer provided');
23
- }
24
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
25
- const decimals = await tokenContract.getPrecission();
26
- return ethers_1.ethers.utils.parseUnits(amount, decimals);
27
- }
28
- /**
29
- * Helper method to format amount from token decimals to human-readable string
30
- * @param amount - The amount as BigNumber with token decimals
31
- * @param tokenAddress - The token contract address
32
- * @returns Promise<string> - The formatted amount as human-readable string
33
- */
34
- async formatAmountWithDecimals(amount, tokenAddress) {
35
- if (!this.perqSdk.signer) {
36
- throw new Error('No signer provided');
37
- }
38
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
39
- const decimals = await tokenContract.getPrecission();
40
- return ethers_1.ethers.utils.formatUnits(amount, decimals);
41
- }
42
- async getTokenPrice(tokenName) {
43
- return this.perqSdk.perqApi.fetchTokenPrice(tokenName);
44
- }
45
- async getAllowance(tokenAddress, spender) {
46
- if (!this.perqSdk.signer) {
47
- throw Error('No signer provided');
48
- }
49
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
50
- const allowance = await tokenContract.getAllowance(await this.perqSdk.signer.getAddress(), spender);
51
- return allowance.toString();
52
- }
53
- async approveAllowance(tokenAddress, amount, spenderAddress) {
54
- if (!this.perqSdk.signer) {
55
- throw Error('No signer provided');
56
- }
57
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
58
- const parsedAmount = await this.parseAmountWithDecimals(amount, tokenAddress);
59
- return await tokenContract.approveToken(spenderAddress, parsedAmount.toString());
60
- }
61
- async transferErc20Token(tokenAddress, amount, receiver) {
62
- if (!this.perqSdk.signer) {
63
- throw Error('No signer provided');
64
- }
65
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
66
- const parsedAmount = await this.parseAmountWithDecimals(amount, tokenAddress);
67
- const txHash = await tokenContract.transfer(receiver, parsedAmount.toString());
68
- return txHash;
69
- }
70
- async wrapEther(amount, tokenAddress) {
71
- if (!this.perqSdk.signer) {
72
- throw Error('No signer provided');
73
- }
74
- const wethContract = new ethers_1.ethers.Contract(tokenAddress, WethTokenAbi_json_1.default, this.perqSdk.signer);
75
- const decimals = await wethContract.decimals();
76
- const amountWithDecimals = ethers_1.ethers.utils.parseUnits(amount, decimals);
77
- const depositTx = await wethContract.deposit({ value: amountWithDecimals });
78
- const receipt = await depositTx.wait();
79
- return receipt.transactionHash;
80
- }
81
- async getERC20TokenAllowance(spender, tokenAddress) {
82
- if (!this.perqSdk.signer) {
83
- throw Error('No signer provided');
84
- }
85
- const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
86
- const allowance = tokenContract.getAllowance(await this.perqSdk.signer.getAddress(), spender);
87
- return allowance;
88
- }
89
- getPerqTokenContractAddress() {
90
- return this.perqSdk.perqConfig.perqTokenAddress;
91
- }
92
- }
93
- exports.default = TokenUtilsPackage;
@@ -1,11 +0,0 @@
1
- import PerqSdk from '../PerqSdk';
2
- import { Earnings, LinkedPodWallets } from '../types';
3
- export default class UserPackage {
4
- private perqSdk;
5
- constructor(perqSdk: PerqSdk);
6
- getEarnings(projectName: string): Promise<Earnings>;
7
- linkSuiWalletWithEthWallet(suiWalletAddress: string): Promise<boolean>;
8
- linkNearWalletWithEthWallet(nearWalletAddress: string): Promise<boolean>;
9
- linkSolanaWalletWithEthWallet(solanaWalletAddress: string): Promise<boolean>;
10
- getLinkedPodWallets(): Promise<LinkedPodWallets>;
11
- }