@raac/rpc 1.0.2-beta.3 → 1.0.2-beta.4

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 (100) hide show
  1. package/{RPCLibrary.ts → RPCLibrary.js} +7 -121
  2. package/assets/{getAsset.ts → getAsset.js} +6 -6
  3. package/assets/{getAssets.ts → getAssets.js} +2 -3
  4. package/assets/{getSupply.ts → getSupply.js} +5 -7
  5. package/configs/chains/index.js +13 -0
  6. package/configs/index.js +17 -0
  7. package/contracts/feeCollector/{claimRewardFromPool.ts → claimRewardFromPool.js} +4 -10
  8. package/contracts/{getContract.ts → getContract.js} +5 -6
  9. package/contracts/{getContractAddress.ts → getContractAddress.js} +4 -6
  10. package/contracts/housePrices/{getLatestPrice.ts → getLatestPrice.js} +6 -8
  11. package/contracts/housePrices/{setOracle.ts → setOracle.js} +6 -8
  12. package/contracts/indexToken/{getNextRandomNFT.ts → getNextRandomNFT.js} +5 -7
  13. package/contracts/indexToken/{redeemNFT.ts → redeemNFT.js} +5 -7
  14. package/contracts/zeno/{createAuction.ts → createAuction.js} +14 -16
  15. package/contracts/zeno/{createZeno.ts → createZeno.js} +8 -10
  16. package/contracts/zeno/{getAuctions.ts → getAuctions.js} +5 -7
  17. package/contracts/zeno/{getZenos.ts → getZenos.js} +5 -7
  18. package/methods/commons/{checkAllowance.ts → checkAllowance.js} +10 -12
  19. package/methods/commons/{estimateGasPrice.ts → estimateGasPrice.js} +5 -7
  20. package/minter/{get.ts → get.js} +6 -8
  21. package/minter/{getApy.ts → getApy.js} +5 -7
  22. package/minter/{tick.ts → tick.js} +5 -7
  23. package/nfts/{getAllTokens.ts → getAllTokens.js} +7 -9
  24. package/nfts/{getBaseUri.ts → getBaseUri.js} +5 -7
  25. package/nfts/{getHousePrice.ts → getHousePrice.js} +6 -8
  26. package/nfts/{getMintFeePercentage.ts → getMintFeePercentage.js} +4 -6
  27. package/nfts/{getMintPrice.ts → getMintPrice.js} +7 -9
  28. package/nfts/{getTokenURI.ts → getTokenURI.js} +7 -9
  29. package/nfts/{getTokensByOwner.ts → getTokensByOwner.js} +8 -10
  30. package/nfts/{getTotalPropertiesCount.ts → getTotalPropertiesCount.js} +5 -7
  31. package/nfts/{mint.ts → mint.js} +7 -9
  32. package/nfts/{setBaseUri.ts → setBaseUri.js} +4 -6
  33. package/nfts/{totalNFTSupply.ts → totalNFTSupply.js} +4 -6
  34. package/package.json +1 -1
  35. package/pools/lendingPool/{borrowFromLendingPool.ts → borrowFromLendingPool.js} +8 -10
  36. package/pools/lendingPool/{borrowFromLendingPoolWithInsurance.ts → borrowFromLendingPoolWithInsurance.js} +8 -10
  37. package/pools/lendingPool/{calculateInsuranceFee.ts → calculateInsuranceFee.js} +9 -11
  38. package/pools/lendingPool/{claimReward.ts → claimReward.js} +5 -7
  39. package/pools/lendingPool/{closeLiquidation.ts → closeLiquidation.js} +7 -9
  40. package/pools/lendingPool/{depositNFTToLendingPool.ts → depositNFTToLendingPool.js} +6 -8
  41. package/pools/lendingPool/{depositToLendingPool.ts → depositToLendingPool.js} +6 -8
  42. package/pools/lendingPool/{getAllUserData.ts → getAllUserData.js} +7 -14
  43. package/pools/lendingPool/{getEligibleUserDeposits.ts → getEligibleUserDeposits.js} +7 -9
  44. package/pools/lendingPool/{getHealthFactor.ts → getHealthFactor.js} +8 -10
  45. package/pools/lendingPool/{getHousePrice.ts → getHousePrice.js} +6 -8
  46. package/pools/lendingPool/{getLendingPoolInfo.ts → getLendingPoolInfo.js} +23 -31
  47. package/pools/lendingPool/{getLendingPoolTotalLiquidity.ts → getLendingPoolTotalLiquidity.js} +7 -10
  48. package/pools/lendingPool/{getPendingReward.ts → getPendingReward.js} +7 -9
  49. package/pools/lendingPool/{getPositionDebt.ts → getPositionDebt.js} +8 -10
  50. package/pools/lendingPool/{getPositionScaledDebt.ts → getPositionScaledDebt.js} +8 -10
  51. package/pools/lendingPool/{getPositionView.ts → getPositionView.js} +9 -11
  52. package/pools/lendingPool/{getPositionsScaledDebt.ts → getPositionsScaledDebt.js} +7 -9
  53. package/pools/lendingPool/{getRawUserDepositsInLendingPool.ts → getRawUserDepositsInLendingPool.js} +7 -9
  54. package/pools/lendingPool/{getUserCollateralValue.ts → getUserCollateralValue.js} +7 -9
  55. package/pools/lendingPool/{initializeLiquidation.ts → initializeLiquidation.js} +8 -10
  56. package/pools/lendingPool/{repayToLendingPool.ts → repayToLendingPool.js} +8 -10
  57. package/pools/lendingPool/{withdrawFromLendingPool.ts → withdrawFromLendingPool.js} +9 -10
  58. package/pools/lendingPool/{withdrawNFTFromLendingPool.ts → withdrawNFTFromLendingPool.js} +7 -9
  59. package/pools/stabilityPool/{calculateRAACRewards.ts → calculateRAACRewards.js} +6 -9
  60. package/pools/stabilityPool/configs/chains/index.js +17 -0
  61. package/pools/stabilityPool/configs/index.js +43 -0
  62. package/pools/stabilityPool/{depositNFTToStabilityPool.ts → depositNFTToStabilityPool.js} +6 -9
  63. package/pools/stabilityPool/{depositToStabilityPool.ts → depositToStabilityPool.js} +6 -8
  64. package/pools/stabilityPool/{getRawUserDepositsInStabilityPool.ts → getRawUserDepositsInStabilityPool.js} +7 -9
  65. package/pools/stabilityPool/{getStabilityPoolInfo.ts → getStabilityPoolInfo.js} +10 -12
  66. package/pools/stabilityPool/{getStabilityPoolTotalDeposits.ts → getStabilityPoolTotalDeposits.js} +6 -8
  67. package/pools/stabilityPool/methods/commons/estimateGasPrice.js +28 -0
  68. package/pools/stabilityPool/pools/stabilityPool/withdrawFromStabilityPool.js +34 -0
  69. package/pools/stabilityPool/utils/artifacts.js +74 -0
  70. package/pools/stabilityPool/utils/contracts.js +82 -0
  71. package/pools/stabilityPool/{withdrawFromStabilityPool.ts → withdrawFromStabilityPool.js} +6 -8
  72. package/ts-to-js.sh +42 -0
  73. package/utils/{artifacts.ts → artifacts.js} +1 -4
  74. package/utils/{contracts.ts → contracts.js} +16 -18
  75. package/wallet/assets/{approveAsset.ts → approveAsset.js} +7 -8
  76. package/wallet/assets/{burnAsset.ts → burnAsset.js} +7 -9
  77. package/wallet/assets/{getAllowance.ts → getAllowance.js} +9 -10
  78. package/wallet/assets/{getAsset.ts → getAsset.js} +6 -7
  79. package/wallet/assets/{getAssets.ts → getAssets.js} +5 -6
  80. package/wallet/assets/{getBalance.ts → getBalance.js} +8 -9
  81. package/wallet/assets/{mintAsset.ts → mintAsset.js} +8 -9
  82. package/wallet/assets/{transferAsset.ts → transferAsset.js} +10 -11
  83. package/configs/chains/index.ts +0 -17
  84. package/configs/index.ts +0 -51
  85. /package/configs/chains/{chain.d.ts → chain.d.js} +0 -0
  86. /package/configs/{createConfig.ts → createConfig.js} +0 -0
  87. /package/contracts/crvUSDToken/{getBalance.ts → getBalance.js} +0 -0
  88. /package/contracts/crvUSDToken/{getTotalSupply.ts → getTotalSupply.js} +0 -0
  89. /package/contracts/rcrvUSDToken/{getBalance.ts → getBalance.js} +0 -0
  90. /package/contracts/rcrvUSDToken/{getTotalSupply.ts → getTotalSupply.js} +0 -0
  91. /package/{custom-types.d.ts → custom-types.d.js} +0 -0
  92. /package/{index.ts → index.js} +0 -0
  93. /package/methods/{approveToken.ts → approveToken.js} +0 -0
  94. /package/methods/{getAssetBalance.ts → getAssetBalance.js} +0 -0
  95. /package/methods/{getAssetsBalance.ts → getAssetsBalance.js} +0 -0
  96. /package/pools/liquidityPool/{getLiquidityPoolInfo.ts → getLiquidityPoolInfo.js} +0 -0
  97. /package/scripts/{index.ts → index.js} +0 -0
  98. /package/tests/{test.ts → test.js} +0 -0
  99. /package/utils/{chain.ts → chain.js} +0 -0
  100. /package/utils/{config.ts → config.js} +0 -0
@@ -1,8 +1,6 @@
1
- import { ethers, Provider } from "ethers";
2
- import { getContractAddress } from "../../contracts/getContractAddress";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { LendingPool } from "../../typechain-types";
6
4
 
7
5
  /**
8
6
  * @description Get the sum of all the scaled debts of a user over all NFTs
@@ -12,9 +10,9 @@ import { LendingPool } from "../../typechain-types";
12
10
  * @returns The debt of the user
13
11
  */
14
12
  async function getPositionsScaledDebt(
15
- chainId: ChainId,
16
- address: string,
17
- provider: Provider
13
+ chainId,
14
+ address,
15
+ provider
18
16
  ) {
19
17
  try {
20
18
  const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
@@ -23,14 +21,14 @@ async function getPositionsScaledDebt(
23
21
  lendingPoolAddress,
24
22
  lendingPoolABI,
25
23
  provider
26
- ) as any as LendingPool;
24
+ );
27
25
 
28
26
  const reward = await lendingPoolContract.getPositionsScaledDebt(address);
29
27
 
30
28
  console.log(`getPositionsScaledDebt result: ${ethers.formatEther(reward)}`);
31
29
 
32
30
  return reward;
33
- } catch (error: any) {
31
+ } catch (error) {
34
32
  console.error("Error in getPositionsScaledDebt:", error);
35
33
  throw error;
36
34
  }
@@ -1,14 +1,12 @@
1
- import { ethers, Provider } from "ethers";
2
- import { getContractAddress } from "../../contracts/getContractAddress";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { LendingPool } from "../../typechain-types";
6
4
 
7
5
  // Get the amount of RToken RAW deposit in the lending pool, without the accured interest
8
6
  async function getRawUserDepositsInLendingPool(
9
- chainId: ChainId,
10
- address: string,
11
- provider: Provider
7
+ chainId,
8
+ address,
9
+ provider
12
10
  ) {
13
11
  try {
14
12
  const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
@@ -17,14 +15,14 @@ async function getRawUserDepositsInLendingPool(
17
15
  lendingPoolAddress,
18
16
  lendingPoolABI,
19
17
  provider
20
- ) as any as LendingPool;
18
+ );
21
19
 
22
20
  const value = await lendingPoolContract.getUserDeposits(address);
23
21
 
24
22
  console.log(`User deposits in lending pool: ${ethers.formatEther(value)}`);
25
23
 
26
24
  return value;
27
- } catch (error: any) {
25
+ } catch (error) {
28
26
  console.error("Error in getRawUserDepositsInLendingPool:", error);
29
27
  throw error;
30
28
  }
@@ -1,8 +1,6 @@
1
- import { ethers, Provider } from "ethers";
2
- import { getContractAddress } from "../../contracts/getContractAddress";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { LendingPool } from "../../typechain-types";
6
4
 
7
5
  /**
8
6
  * @description Sum of the prices of all the NFTS
@@ -12,9 +10,9 @@ import { LendingPool } from "../../typechain-types";
12
10
  * @returns The total value of the collateral
13
11
  */
14
12
  async function getUserCollateralValue(
15
- chainId: ChainId,
16
- address: string,
17
- provider: Provider
13
+ chainId,
14
+ address,
15
+ provider
18
16
  ) {
19
17
  try {
20
18
  const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
@@ -23,14 +21,14 @@ async function getUserCollateralValue(
23
21
  lendingPoolAddress,
24
22
  lendingPoolABI,
25
23
  provider
26
- ) as any as LendingPool;
24
+ );
27
25
 
28
26
  const reward = await lendingPoolContract.getUserCollateralValue(address);
29
27
 
30
28
  console.log(`getUserCollateralValue result: ${ethers.formatEther(reward)}`);
31
29
 
32
30
  return reward;
33
- } catch (error: any) {
31
+ } catch (error) {
34
32
  console.error("Error in getUserCollateralValue:", error);
35
33
  throw error;
36
34
  }
@@ -1,8 +1,6 @@
1
- import { ethers, Provider, Signer } from "ethers";
2
- import { getContractAddress } from "../../contracts/getContractAddress";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { LendingPool } from "../../typechain-types";
6
4
 
7
5
  /**
8
6
  * @description Get the sum of all the scaled debts of a user over all NFTs
@@ -12,10 +10,10 @@ import { LendingPool } from "../../typechain-types";
12
10
  * @returns The debt of the user
13
11
  */
14
12
  async function initializeLiquidation(
15
- chainId: ChainId,
16
- address: string,
17
- tokenId: string,
18
- signer: Signer
13
+ chainId,
14
+ address,
15
+ tokenId,
16
+ signer
19
17
  ) {
20
18
  try {
21
19
  const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
@@ -24,7 +22,7 @@ async function initializeLiquidation(
24
22
  lendingPoolAddress,
25
23
  lendingPoolABI,
26
24
  signer
27
- ) as any as LendingPool;
25
+ );
28
26
 
29
27
  const tx = await lendingPoolContract.initiateLiquidation(address, tokenId);
30
28
  await tx.wait();
@@ -32,7 +30,7 @@ async function initializeLiquidation(
32
30
  console.log(`initializeLiquidation result: ${tx.hash}`);
33
31
 
34
32
  return tx;
35
- } catch (error: any) {
33
+ } catch (error) {
36
34
  console.error("Error in initializeLiquidation:", error);
37
35
  throw error;
38
36
  }
@@ -1,14 +1,12 @@
1
- import { ethers, Provider, Signer } from "ethers";
2
- import { getContractAddress } from "../../contracts/getContractAddress";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { LendingPool } from "../../typechain-types";
6
4
 
7
5
  async function repayToLendingPool(
8
- chainId: ChainId,
9
- tokenId: string,
10
- amount: string,
11
- signer: Signer
6
+ chainId,
7
+ tokenId,
8
+ amount,
9
+ signer
12
10
  ) {
13
11
  try {
14
12
  const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
@@ -17,7 +15,7 @@ async function repayToLendingPool(
17
15
  lendingPoolAddress,
18
16
  lendingPoolABI,
19
17
  signer
20
- ) as any as LendingPool;
18
+ );
21
19
 
22
20
  const amountInWei = ethers.parseEther(amount.toString());
23
21
  console.log("Repaying amount in wei:", amountInWei.toString());
@@ -29,7 +27,7 @@ async function repayToLendingPool(
29
27
  console.log(`Transaction hash: ${receipt?.hash}`);
30
28
 
31
29
  return receipt;
32
- } catch (error: any) {
30
+ } catch (error) {
33
31
  console.error("Error in repayToLendingPool:", error);
34
32
  throw error;
35
33
  }
@@ -1,13 +1,12 @@
1
- import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../contracts/getContractAddress";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
4
  import estimateGasPrice from "../../methods/commons/estimateGasPrice";
5
- import { ChainId } from "../../configs/chains";
6
- import { ERC20, LendingPool } from "../../typechain-types";
5
+
7
6
  async function withdrawFromLendingPool(
8
- chainId: ChainId,
9
- amount: bigint,
10
- signer: Signer
7
+ chainId,
8
+ amount,
9
+ signer
11
10
  ) {
12
11
  try {
13
12
  const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
@@ -19,12 +18,12 @@ async function withdrawFromLendingPool(
19
18
  lendingPoolAddress,
20
19
  lendingPoolABI,
21
20
  signer
22
- ) as any as LendingPool;
21
+ );
23
22
  const rTokenContract = new ethers.Contract(
24
23
  rtokenAddress,
25
24
  assetABI,
26
25
  signer
27
- ) as any as ERC20;
26
+ );
28
27
 
29
28
  const amountInWei = ethers.parseEther(amount.toString());
30
29
  const { maxFeePerGas } = await estimateGasPrice(signer);
@@ -59,7 +58,7 @@ async function withdrawFromLendingPool(
59
58
  console.log(`Transaction hash: ${receipt?.hash}`);
60
59
 
61
60
  return receipt;
62
- } catch (error: any) {
61
+ } catch (error) {
63
62
  console.error("Error in withdrawFromLendingPool:", error);
64
63
  throw error;
65
64
  }
@@ -1,13 +1,11 @@
1
- import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { LendingPool } from "../../typechain-types";
6
4
 
7
5
  async function withdrawNFTFromLendingPool(
8
- chainId: ChainId,
9
- tokenId: string,
10
- signer: Signer
6
+ chainId,
7
+ tokenId,
8
+ signer
11
9
  ) {
12
10
  if (!signer) {
13
11
  throw new Error("Wallet not connected");
@@ -21,14 +19,14 @@ async function withdrawNFTFromLendingPool(
21
19
  lendingPoolAddress,
22
20
  lendingPoolABI,
23
21
  signer
24
- ) as any as LendingPool;
22
+ );
25
23
 
26
24
  const tx = await lendingPoolContract.withdrawNFT(tokenId);
27
25
  await tx.wait();
28
26
 
29
27
  console.log(`Withdrawn NFT with token ID ${tokenId} from lending pool`);
30
28
  return tx;
31
- } catch (error: any) {
29
+ } catch (error) {
32
30
  console.error("Error withdrawing NFT from lending pool:", error);
33
31
  throw new Error(
34
32
  `Failed to withdraw NFT from lending pool: ${error.message}`
@@ -1,14 +1,11 @@
1
1
  import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import estimateGasPrice from "../../methods/commons/estimateGasPrice";
5
- import { ChainId } from "../../configs/chains/index";
6
- import { StabilityPool } from "../../typechain-types";
7
4
 
8
5
  async function calculateRAACRewards(
9
- chainId: ChainId,
10
- address: string,
11
- signer: Signer
6
+ chainId,
7
+ address,
8
+ signer
12
9
  ) {
13
10
  if (!signer) {
14
11
  throw new Error("Wallet not connected");
@@ -22,13 +19,13 @@ async function calculateRAACRewards(
22
19
  stabilityPoolAddress,
23
20
  stabilityPoolABI,
24
21
  signer
25
- ) as any as StabilityPool;
22
+ );
26
23
 
27
24
  const calculateRAACRewards =
28
25
  await stabilityPoolContract.calculateRaacRewards(address);
29
26
 
30
27
  return ethers.formatEther(calculateRAACRewards);
31
- } catch (error: any) {
28
+ } catch (error) {
32
29
  throw new Error(`Error calculating RAAC rewards: ${error.message}`);
33
30
  }
34
31
  }
@@ -0,0 +1,17 @@
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
+ exports.configs = void 0;
7
+ // @ts-ignore
8
+ const _8453_json_1 = __importDefault(require("./8453.json")); // assert { type: "json" };
9
+ const _17000_json_1 = __importDefault(require("./17000.json")); // assert { type: "json" };
10
+ const _11155111_json_1 = __importDefault(require("./11155111.json")); // assert { type: "json" };
11
+ const chains = {
12
+ 8453: _8453_json_1.default,
13
+ 17000: _17000_json_1.default, // the interface is the same for all the chains, so taking this
14
+ 11155111: _11155111_json_1.default,
15
+ };
16
+ exports.default = chains;
17
+ exports.configs = chains;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ // let fs;
3
+ // let path;
4
+ // let fileURLToPath;
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getChainsConfig = getChainsConfig;
10
+ exports.getChainConfig = getChainConfig;
11
+ exports.setChainConfig = setChainConfig;
12
+ const index_1 = __importDefault(require("./chains/index"));
13
+ function getChainsConfig() {
14
+ // if (typeof window === 'undefined') {
15
+ // // Server-side logic
16
+ // const __filename = fileURLToPath(import.meta.url);
17
+ // const __dirname = path.dirname(__filename);
18
+ // const chainsDir = `${__dirname}/chains`;
19
+ // const chainsFiles = fs.readdirSync(chainsDir).filter(file => file.endsWith('.json'));
20
+ // const chains = {};
21
+ // for(const chainFileName of chainsFiles) {
22
+ // const chainId = chainFileName.split('.')[0];
23
+ // const chainConfig = fs.readFileSync(`${chainsDir}/${chainFileName}`, 'utf8');
24
+ // chains[chainId] = JSON.parse(chainConfig);
25
+ // }
26
+ // return chains;
27
+ // } else {
28
+ // const chainConfigs = {
29
+ // 8453: chain8453,
30
+ // };
31
+ // // Client-side logic via API ?
32
+ // return chainConfigs;
33
+ // }
34
+ return index_1.default;
35
+ }
36
+ function setChainConfig(chainId, config) {
37
+ index_1.default[chainId] = config;
38
+ }
39
+ function getChainConfig(chainId) {
40
+ const chains = getChainsConfig();
41
+ return chains[chainId];
42
+ }
43
+ exports.default = { getChainsConfig, getChainConfig, setChainConfig };
@@ -1,14 +1,11 @@
1
1
  import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import estimateGasPrice from "../../methods/commons/estimateGasPrice";
5
- import { ChainId } from "../../configs/chains/index";
6
- import { StabilityPool } from "../../typechain-types";
7
4
 
8
5
  async function depositNFTToStabilityPool(
9
- chainId: ChainId,
10
- tokenId: string,
11
- signer: Signer
6
+ chainId,
7
+ tokenId,
8
+ signer
12
9
  ) {
13
10
  if (!signer) {
14
11
  throw new Error("Wallet not connected");
@@ -21,7 +18,7 @@ async function depositNFTToStabilityPool(
21
18
  stabilityPoolAddress,
22
19
  abi,
23
20
  signer
24
- ) as any as StabilityPool;
21
+ );
25
22
 
26
23
  const RAACNFTAddress = getContractAddress(chainId, "raacnft");
27
24
  const raacNFTABI = getABI("raacnft");
@@ -58,7 +55,7 @@ async function depositNFTToStabilityPool(
58
55
  receipt?.hash
59
56
  );
60
57
  return receipt;
61
- } catch (error: any) {
58
+ } catch (error) {
62
59
  console.error(`Error depositing NFT to Stability Pool:`, error);
63
60
  throw new Error(`NFT Deposit to Stability Pool failed: ${error.message}`);
64
61
  }
@@ -1,14 +1,12 @@
1
1
  import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
4
  import estimateGasPrice from "../../methods/commons/estimateGasPrice";
5
- import { ChainId } from "../../configs/chains/index";
6
- import { StabilityPool } from "../../typechain-types";
7
5
 
8
6
  async function depositToStabilityPool(
9
- chainId: ChainId,
10
- amount: string,
11
- signer: Signer
7
+ chainId,
8
+ amount,
9
+ signer
12
10
  ) {
13
11
  if (!signer) {
14
12
  throw new Error("Wallet not connected");
@@ -21,7 +19,7 @@ async function depositToStabilityPool(
21
19
  stabilityPoolAddress,
22
20
  abi,
23
21
  signer
24
- ) as any as StabilityPool;
22
+ );
25
23
 
26
24
  const amountInWei = ethers.parseEther(amount);
27
25
  const { maxFeePerGas } = await estimateGasPrice(signer);
@@ -38,7 +36,7 @@ async function depositToStabilityPool(
38
36
  receipt?.hash
39
37
  );
40
38
  return receipt;
41
- } catch (error: any) {
39
+ } catch (error) {
42
40
  console.error(`Error depositing to Stability Pool:`, error);
43
41
  throw new Error(`Deposit to Stability Pool failed: ${error.message}`);
44
42
  }
@@ -1,14 +1,12 @@
1
- import { ethers, Provider } from "ethers";
2
- import { getContractAddress } from "../../contracts/getContractAddress";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { StabilityPool } from "../../typechain-types";
6
4
 
7
5
  // Get the amount of RToken RAW deposit in the lending pool, without the accured interest
8
6
  async function getRawUserDepositInStabilityPool(
9
- chainId: ChainId,
10
- address: string,
11
- provider: Provider
7
+ chainId,
8
+ address,
9
+ provider
12
10
  ) {
13
11
  try {
14
12
  const stabilityPoolAddress = getContractAddress(chainId, "stabilitypool");
@@ -17,7 +15,7 @@ async function getRawUserDepositInStabilityPool(
17
15
  stabilityPoolAddress,
18
16
  stabilityPoolABI,
19
17
  provider
20
- ) as any as StabilityPool;
18
+ );
21
19
 
22
20
  const value = await stabilityPoolContract.getUserDeposit(address);
23
21
 
@@ -26,7 +24,7 @@ async function getRawUserDepositInStabilityPool(
26
24
  );
27
25
 
28
26
  return value;
29
- } catch (error: any) {
27
+ } catch (error) {
30
28
  console.error("Error in getRawUserDepositInStabilityPool:", error);
31
29
  throw error;
32
30
  }
@@ -1,13 +1,11 @@
1
- import { ethers, Provider } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { StabilityPool } from "../../typechain-types";
6
4
 
7
5
  async function getStabilityPoolInfo(
8
- chainId: ChainId,
9
- address: string,
10
- provider: Provider
6
+ chainId,
7
+ address,
8
+ provider
11
9
  ) {
12
10
  try {
13
11
  const stabilityPoolAddress = getContractAddress(chainId, "stabilitypool");
@@ -16,9 +14,9 @@ async function getStabilityPoolInfo(
16
14
  stabilityPoolAddress,
17
15
  abi,
18
16
  provider
19
- ) as any as StabilityPool;
17
+ );
20
18
 
21
- const handleError = (operation: string) => (error: any) => {
19
+ const handleError = (operation) => (error) => {
22
20
  if (error.code === "BAD_DATA") {
23
21
  console.log(
24
22
  `BAD_DATA from getStabilityPoolInfo - ${operation}:`,
@@ -68,12 +66,12 @@ async function getStabilityPoolInfo(
68
66
 
69
67
  // Fetch RAAC Minter information if needed for APY calculation
70
68
  const raacMinterAddress = getContractAddress(chainId, "raacminter");
71
- let apy: bigint = 0n;
69
+ let apy = 0n;
72
70
 
73
71
  if (raacMinterAddress && raacMinterAddress !== ethers.ZeroAddress) {
74
72
  const raacMinterABI = getABI("raacminter");
75
73
  const raacMinterContract = new ethers.Contract(
76
- raacMinterAddress as string,
74
+ raacMinterAddress,
77
75
  raacMinterABI,
78
76
  provider
79
77
  );
@@ -102,7 +100,7 @@ async function getStabilityPoolInfo(
102
100
  };
103
101
 
104
102
  return result;
105
- } catch (error: any) {
103
+ } catch (error) {
106
104
  console.error("Error fetching stability pool info:", error);
107
105
  throw error;
108
106
  }
@@ -1,12 +1,10 @@
1
- import { BrowserProvider, ethers, Provider } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../contracts/getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { StabilityPool } from "../../typechain-types";
6
4
 
7
5
  async function getStabilityPoolTotalDeposits(
8
- chainId: ChainId,
9
- provider: Provider
6
+ chainId,
7
+ provider
10
8
  ) {
11
9
  try {
12
10
  const stabilityPoolAddress = getContractAddress(chainId, "stabilitypool");
@@ -15,10 +13,10 @@ async function getStabilityPoolTotalDeposits(
15
13
  stabilityPoolAddress,
16
14
  abi,
17
15
  provider
18
- ) as any as StabilityPool;
16
+ );
19
17
  const totalDeposits = await stabilityPoolContract.getTotalDeposits();
20
18
  return totalDeposits;
21
- } catch (error: any) {
19
+ } catch (error) {
22
20
  console.error("Error fetching total deposits:", error);
23
21
  throw error;
24
22
  }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.estimateGasPrice = void 0;
4
+ const estimateGasPrice = async (signer) => {
5
+ const provider = signer.provider;
6
+ try {
7
+ const feeData = await provider.getFeeData();
8
+ const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
9
+ // Fix for maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two
10
+ const maxFeePerGas = maxPriorityFeePerGas && feeData.maxFeePerGas &&
11
+ feeData.maxFeePerGas < maxPriorityFeePerGas ?
12
+ maxPriorityFeePerGas : feeData.maxFeePerGas;
13
+ return {
14
+ maxFeePerGas,
15
+ maxPriorityFeePerGas,
16
+ };
17
+ }
18
+ catch (error) {
19
+ console.log("Error getting gas price", error);
20
+ if (provider === null || provider === void 0 ? void 0 : provider.getGasPrice) {
21
+ const gasPrice = await provider.getGasPrice();
22
+ return { gasPrice };
23
+ }
24
+ return { gasPrice: 0 };
25
+ }
26
+ };
27
+ exports.estimateGasPrice = estimateGasPrice;
28
+ exports.default = exports.estimateGasPrice;
@@ -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 contracts_1 = require("../../utils/contracts");
8
+ const artifacts_1 = require("../../utils/artifacts");
9
+ const estimateGasPrice_1 = __importDefault(require("../../methods/commons/estimateGasPrice"));
10
+ async function withdrawFromStabilityPool(chainId, amount, signer) {
11
+ if (!signer) {
12
+ throw new Error("Wallet not connected");
13
+ }
14
+ try {
15
+ const stabilityPoolAddress = (0, contracts_1.getContractAddress)(chainId, "stabilitypool");
16
+ const abi = (0, artifacts_1.getABI)("stabilitypool");
17
+ const stabilityPoolContract = new ethers_1.ethers.Contract(stabilityPoolAddress, abi, signer);
18
+ const amountInWei = ethers_1.ethers.parseEther(amount);
19
+ const { maxFeePerGas } = await (0, estimateGasPrice_1.default)(signer);
20
+ const tx = await stabilityPoolContract.withdraw(amountInWei.toString(), {
21
+ maxFeePerGas,
22
+ nonce: await signer.getNonce(),
23
+ });
24
+ console.log(`Withdrawal transaction sent to Stability Pool:`, tx.hash);
25
+ const receipt = await tx.wait();
26
+ console.log(`Withdrawn ${amount} from Stability Pool successfully:`, receipt === null || receipt === void 0 ? void 0 : receipt.hash);
27
+ return receipt;
28
+ }
29
+ catch (error) {
30
+ console.error(`Error withdrawing from Stability Pool:`, error);
31
+ throw new Error(`Withdrawal from Stability Pool failed: ${error.message}`);
32
+ }
33
+ }
34
+ exports.default = withdrawFromStabilityPool;