@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
@@ -109,121 +109,7 @@ import calculateInsuranceFee from "./pools/lendingPool/calculateInsuranceFee";
109
109
  import getTotalPropertiesCount from "./nfts/getTotalPropertiesCount";
110
110
 
111
111
  class RPCLibrary {
112
- signer: Signer | null;
113
- isConnected: boolean;
114
- address: JsonRpcSigner | string;
115
- chainId: ChainId | bigint | null;
116
- privateKey: any;
117
-
118
- // valid
119
- assets: {
120
- getAsset: typeof getAsset;
121
- getAssets: typeof getAssets;
122
- getSupply: typeof getSupply;
123
- };
124
- // valid
125
- wallet: {
126
- assets: {
127
- getBalance: typeof getWalletBalance;
128
- getAllowance: typeof getWalletAllowance;
129
- getAsset: typeof getWalletAsset;
130
- getAssets: typeof getWalletAssets;
131
- transferAsset: typeof transferAsset;
132
- approveAsset: typeof approveAsset;
133
- mintAsset: typeof mintAsset;
134
- burnAsset: typeof burnAsset;
135
- };
136
- };
137
- nfts: {
138
- getBaseUri: typeof getBaseUri;
139
- mint: typeof mintNFT;
140
- getHousePrice: typeof getNFTHousePrice;
141
- getTokensByOwner: typeof getTokensByOwner;
142
- setBaseUri: typeof setNFTBaseUri;
143
- totalSupply: typeof totalNFTSupply;
144
- getMintPrice: typeof getMintPrice;
145
- getMintFeePercentage: typeof getMintFeePercentage;
146
- getAllTokens: typeof getAllTokens;
147
- getTokenURI: typeof getTokenURI;
148
- getTotalPropertiesCount: typeof getTotalPropertiesCount;
149
- };
150
- contracts: {
151
- housePrices: {
152
- getLatestPrice: typeof getLatestPrice;
153
- setOracle: typeof setOracle;
154
- };
155
- minter: { tick: typeof tick; get: typeof get; getApy: typeof getApy };
156
- getContractAddress: typeof getContractAddress;
157
- getContract: typeof getContract;
158
- feeCollector: {
159
- claimRewardFromPool: typeof claimRewardFromPool;
160
- };
161
- indexToken: {
162
- getNextRandomNFT: typeof getNextRandomNFT;
163
- redeemNFT: typeof redeemNFT;
164
- };
165
- };
166
- pools: {
167
- stabilityPool: {
168
- getStabilityPoolInfo: typeof getStabilityPoolInfo;
169
- depositToStabilityPool: typeof depositToStabilityPool;
170
- withdrawFromStabilityPool: typeof withdrawFromStabilityPool;
171
- calculateRAACRewards: typeof calculateRAACRewards;
172
- getRawUserDepositInStabilityPool: typeof getRawUserDepositInStabilityPool;
173
- depositNFTToStabilityPool: typeof depositNFTToStabilityPool;
174
- };
175
- // LendingPool
176
- lendingPool: {
177
- repayToLendingPool: typeof repayToLendingPool;
178
- borrowFromLendingPool: typeof borrowFromLendingPool;
179
- getHousePrice: typeof getHousePrice;
180
- depositNFTToLendingPool: typeof depositNFTToLendingPool;
181
- withdrawNFTFromLendingPool: typeof withdrawNFTFromLendingPool;
182
- getLendingPoolInfo: typeof getLendingPoolInfo;
183
- getAllUserData: typeof getAllUserData;
184
- claimReward: typeof claimReward;
185
- getPendingReward: typeof getPendingReward;
186
- getRawUserDepositsInLendingPool: typeof getRawUserDepositsInLendingPool;
187
- getEligibleUserDeposits: typeof getEligibleUserDeposits;
188
- getHealthFactor: typeof getHealthFactor;
189
- getPositionDebt: typeof getPositionDebt;
190
- getPositionScaledDebt: typeof getPositionScaledDebt;
191
- getPositionsScaledDebt: typeof getPositionsScaledDebt;
192
- getPositionView: typeof getPositionView;
193
- getUserCollateralValue: typeof getUserCollateralValue;
194
- depositToLendingPool: typeof depositToLendingPool;
195
- initializeLiquidation: typeof initializeLiquidation;
196
- closeLiquidation: typeof closeLiquidation;
197
- borrowFromLendingPoolWithInsurance: typeof borrowFromLendingPoolWithInsurance;
198
- calculateInsuranceFee: typeof calculateInsuranceFee;
199
- };
200
- depositToLendingPool: typeof depositToLendingPool;
201
- withdrawFromLendingPool: typeof withdrawFromLendingPool;
202
- getLendingPoolTotalLiquidity: typeof getLendingPoolTotalLiquidity;
203
- calculateRAACRewards: typeof calculateRAACRewards;
204
- repayToLendingPool: typeof repayToLendingPool;
205
- borrowFromLendingPool: typeof borrowFromLendingPool;
206
- getHousePrice: typeof getHousePrice;
207
- // StabilityPool
208
- getStabilityPoolTotalDeposits: typeof getStabilityPoolTotalDeposits;
209
- getStabilityPoolInfo: typeof getStabilityPoolInfo;
210
- depositToStabilityPool: typeof depositToStabilityPool;
211
- withdrawFromStabilityPool: typeof withdrawFromStabilityPool;
212
- };
213
- zeno: {
214
- createAuction: typeof createAuction;
215
- getAuctions: typeof getAuctions;
216
- createZeno: typeof createZeno;
217
- getZenos: typeof getZenos;
218
- };
219
- provider: any;
220
-
221
- estimateGasPrice: any;
222
- checkAllowance!: typeof checkAllowance;
223
- getChainsConfig!: typeof getChainsConfig;
224
- setChainsConfig!: typeof setChainConfig;
225
-
226
- constructor(privateKey?: string) {
112
+ constructor(privateKey) {
227
113
  this.signer = null;
228
114
  this.isConnected = false;
229
115
  this.address = "";
@@ -338,7 +224,7 @@ class RPCLibrary {
338
224
  };
339
225
  }
340
226
 
341
- async getWallet(privateKey: string, provider: Provider) {
227
+ async getWallet(privateKey, provider) {
342
228
  // @ts-ignore
343
229
  if (typeof window !== "undefined" && window.ethereum) {
344
230
  // Browser environment with MetaMask
@@ -354,7 +240,7 @@ class RPCLibrary {
354
240
  }
355
241
  }
356
242
 
357
- async getProvider(chainId: ChainId) {
243
+ async getProvider(chainId) {
358
244
  if (
359
245
  typeof globalThis !== "undefined" &&
360
246
  globalThis.window && // @ts-ignore
@@ -371,7 +257,7 @@ class RPCLibrary {
371
257
  return provider;
372
258
  }
373
259
 
374
- async getSigner(chainId: ChainId, address: string) {
260
+ async getSigner(chainId, address) {
375
261
  const provider = await this.getProvider(chainId);
376
262
  const signer = await provider.getSigner(address);
377
263
  return signer;
@@ -396,7 +282,7 @@ class RPCLibrary {
396
282
  this.signer = await provider.getSigner();
397
283
  this.address = await this.signer.getAddress();
398
284
  this.isConnected = true;
399
- } catch (error: any) {
285
+ } catch (error) {
400
286
  console.error("Failed to connect wallet:", error);
401
287
  throw new Error(`Failed to connect wallet: ${error.message}`);
402
288
  }
@@ -408,7 +294,7 @@ class RPCLibrary {
408
294
  this.signer = new ethers.Wallet(this.privateKey, this.provider);
409
295
  this.address = await this.signer.getAddress();
410
296
  this.isConnected = true;
411
- } catch (error: any) {
297
+ } catch (error) {
412
298
  console.error("Failed to connect wallet:", error);
413
299
  throw new Error(`Failed to connect wallet: ${error.message}`);
414
300
  }
@@ -434,7 +320,7 @@ class RPCLibrary {
434
320
  }
435
321
 
436
322
  // Mine a block
437
- async mineBlock(wallet: Eip1193Provider) {
323
+ async mineBlock(wallet) {
438
324
  const provider = new ethers.BrowserProvider(wallet);
439
325
  await provider.send("evm_mine", []);
440
326
  // await provider.send('evm_mine', []);
@@ -5,21 +5,21 @@ import { AssetType } from "../utils/artifacts";
5
5
  import { Provider } from "ethers";
6
6
 
7
7
  async function getAsset(
8
- chainId: ChainId,
9
- assetId: AssetType,
10
- provider: Provider
8
+ chainId,
9
+ assetId,
10
+ provider
11
11
  ) {
12
12
  try {
13
13
  const { assets } = getConfig(chainId);
14
- const asset: any = Object.values(assets).find(
15
- (asset: any) => asset.id === assetId
14
+ const asset = Object.values(assets).find(
15
+ (asset) => asset.id === assetId
16
16
  );
17
17
  if (!asset) {
18
18
  throw new Error(`Asset ${assetId} not found on chain ${chainId}`);
19
19
  }
20
20
  asset.supply = await getSupply(chainId, assetId, provider);
21
21
  return asset;
22
- } catch (error: any) {
22
+ } catch (error) {
23
23
  console.error(`Error getting asset ${assetId}:`, error);
24
24
  return 0;
25
25
  }
@@ -2,16 +2,15 @@ import { Provider } from "ethers";
2
2
  import { ChainId } from "../configs/chains";
3
3
  import { getConfig } from "../utils/contracts";
4
4
 
5
- async function getAssets(chainId: ChainId, provider: Provider) {
5
+ async function getAssets(chainId, provider) {
6
6
  const { assets } = getConfig(chainId);
7
- const responses: any = {};
7
+ const responses = {};
8
8
 
9
9
  const assetIds = Object.keys(assets);
10
10
  const assetPromises = assetIds.map(async (assetId) => {
11
11
  // @ts-ignore
12
12
  const asset = await this.getAsset(chainId, assetId, provider);
13
13
  responses[assetId] = {
14
- // @ts-ignore
15
14
  ...assets[assetId],
16
15
  ...asset,
17
16
  };
@@ -1,12 +1,10 @@
1
- import { ethers, Provider } from "ethers";
1
+ import { ethers } from "ethers";
2
2
  import { getContractAddress } from "../utils/contracts";
3
- import { ChainId } from "../configs/chains";
4
- import { AssetType } from "../utils/artifacts";
5
3
 
6
4
  async function getSupply(
7
- chainId: ChainId,
8
- assetId: AssetType,
9
- provider: Provider
5
+ chainId,
6
+ assetId,
7
+ provider
10
8
  ) {
11
9
  try {
12
10
  const SUPPLY_ABI = ["function totalSupply() view returns (uint256)"];
@@ -14,7 +12,7 @@ async function getSupply(
14
12
  const contract = new ethers.Contract(contractAddress, SUPPLY_ABI, provider);
15
13
  const supply = await contract.totalSupply();
16
14
  return ethers.formatEther(supply);
17
- } catch (error: any) {
15
+ } catch (error) {
18
16
  console.error(`Error getting supply for asset ${assetId}:`, error);
19
17
  return 0;
20
18
  }
@@ -0,0 +1,13 @@
1
+ // @ts-ignore
2
+ import chain8453 from "./8453.json"; // assert { type: "json" };
3
+ import chain17000 from "./17000.json"; // assert { type: "json" };
4
+ import chain11155111 from "./11155111.json"; // assert { type: "json" };
5
+
6
+ const chains = {
7
+ 8453: chain8453,
8
+ 17000: chain17000, // the interface is the same for all the chains, so taking this
9
+ 11155111: chain11155111,
10
+ };
11
+
12
+ export default chains;
13
+ export const configs = chains;
@@ -0,0 +1,17 @@
1
+ import chains from "./chains/index";
2
+
3
+ function getChainsConfig() {
4
+ return chains;
5
+ }
6
+
7
+ function setChainConfig(chainId, config) {
8
+ chains[chainId] = config;
9
+ }
10
+
11
+ function getChainConfig(chainId) {
12
+ const chains = getChainsConfig();
13
+ return chains[chainId];
14
+ }
15
+
16
+ export default { getChainsConfig, getChainConfig, setChainConfig };
17
+ export { getChainsConfig, getChainConfig, setChainConfig };
@@ -1,13 +1,7 @@
1
- import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
3
- import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { AuctionFactory, FeeCollector } from "../../typechain-types";
6
-
7
1
  async function claimRewardFromPool(
8
- chainId: ChainId,
9
- poolAddress: string,
10
- signer: Signer
2
+ chainId,
3
+ poolAddress,
4
+ signer
11
5
  ) {
12
6
  if (!signer) {
13
7
  throw new Error("Wallet not connected");
@@ -24,7 +18,7 @@ async function claimRewardFromPool(
24
18
  // const tx = await feeCollector.claimRewardFromPool(poolAddress);
25
19
  // await tx.wait();
26
20
  // console.log(`Claimed reward from pool: ${poolAddress}`);
27
- } catch (error: any) {
21
+ } catch (error) {
28
22
  console.error("Error FEECOLLECTOR claiming reward from pool:", error);
29
23
  throw new Error(`Failed to claim reward from pool: ${error.message}`);
30
24
  }
@@ -1,12 +1,11 @@
1
- import { ethers, Signer } from "ethers";
1
+ import { ethers } from "ethers";
2
2
  import getContractAddress from "./getContractAddress";
3
- import { ChainId } from "../configs/chains/index";
4
3
  import { ContractType } from "../utils/artifacts";
5
4
 
6
5
  export default async function getContract(
7
- chainId: ChainId,
8
- contractName: ContractType,
9
- signer: Signer
6
+ chainId,
7
+ contractName,
8
+ signer
10
9
  ) {
11
10
  if (!signer) {
12
11
  throw new Error("Signer is required");
@@ -14,7 +13,7 @@ export default async function getContract(
14
13
  const contractAddress = getContractAddress(chainId, contractName);
15
14
 
16
15
  // You'll need to import the ABI for the contract. This is just a placeholder.
17
- const abi: any[] = []; // Replace with actual ABI
16
+ const abi = []; // Replace with actual ABI
18
17
 
19
18
  const contract = new ethers.Contract(contractAddress, abi, signer);
20
19
  return contract;
@@ -1,6 +1,4 @@
1
- import { Chain } from "../configs/chains/chain";
2
- import configs, { ChainId } from "../configs/chains";
3
- import { ContractType } from "../utils/artifacts";
1
+ import configs from "../configs/chains";
4
2
 
5
3
  /**
6
4
  * Get the contract address for a given asset on a specific chain
@@ -9,8 +7,8 @@ import { ContractType } from "../utils/artifacts";
9
7
  * @returns {string}
10
8
  */
11
9
  export const getContractAddress = (
12
- chainId: ChainId,
13
- contractName: ContractType
10
+ chainId,
11
+ contractName
14
12
  ) => {
15
13
  const normalizedContractName = contractName.toLowerCase();
16
14
 
@@ -29,7 +27,7 @@ export const getContractAddress = (
29
27
  "assets",
30
28
  "pools",
31
29
  "nfts",
32
- ] as (keyof Chain)[];
30
+ ];
33
31
 
34
32
  let address = null;
35
33
  for (const key of lookupKeys) {
@@ -1,13 +1,11 @@
1
- import { ethers, Provider } from "ethers";
1
+ import { ethers } from "ethers";
2
2
  import { getContractAddress } from "../../utils/contracts";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { RAACHousePrices } from "../../typechain-types";
6
4
 
7
5
  async function getLatestPrice(
8
- chainId: ChainId,
9
- tokenId: string,
10
- provider: Provider
6
+ chainId,
7
+ tokenId,
8
+ provider
11
9
  ) {
12
10
  try {
13
11
  const raacHousePricesAddress = getContractAddress(
@@ -20,14 +18,14 @@ async function getLatestPrice(
20
18
  raacHousePricesAddress,
21
19
  raacHousePricesABI,
22
20
  provider
23
- ) as any as RAACHousePrices;
21
+ );
24
22
 
25
23
  const [price, timestamp] = await raacHousePricesContract.getLatestPrice(
26
24
  tokenId
27
25
  );
28
26
 
29
27
  return { price, timestamp };
30
- } catch (error: any) {
28
+ } catch (error) {
31
29
  console.error("Error getting latest price:", error);
32
30
  return { price: -1n, timestamp: -1 };
33
31
  // console.error('Error getting latest price:', error);
@@ -1,13 +1,11 @@
1
- import { ethers, Signer } from "ethers";
1
+ import { ethers } from "ethers";
2
2
  import { getContractAddress } from "../../utils/contracts";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { RAACHousePrices } from "../../typechain-types";
6
4
 
7
5
  async function setOracle(
8
- chainId: ChainId,
9
- newOracleAddress: string,
10
- signer: Signer
6
+ chainId,
7
+ newOracleAddress,
8
+ signer
11
9
  ) {
12
10
  if (!signer) {
13
11
  throw new Error("Wallet not connected");
@@ -24,14 +22,14 @@ async function setOracle(
24
22
  raacHousePricesAddress,
25
23
  raacHousePricesABI,
26
24
  signer
27
- ) as any as RAACHousePrices;
25
+ );
28
26
 
29
27
  const tx = await raacHousePricesContract.setOracle(newOracleAddress);
30
28
  await tx.wait();
31
29
 
32
30
  console.log(`Oracle address updated to: ${newOracleAddress}`);
33
31
  return tx;
34
- } catch (error: any) {
32
+ } catch (error) {
35
33
  console.error("Error setting oracle:", error);
36
34
  throw new Error(`Failed to set oracle: ${error.message}`);
37
35
  }
@@ -1,10 +1,8 @@
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 { IndexToken } from "../../typechain-types";
6
4
 
7
- async function getNextRandomNFT(chainId: ChainId, provider: Provider) {
5
+ async function getNextRandomNFT(chainId, provider) {
8
6
  try {
9
7
  const indexTokenAddress = getContractAddress(chainId, "indextoken");
10
8
  const indexTokenABI = getABI("indextoken");
@@ -12,7 +10,7 @@ async function getNextRandomNFT(chainId: ChainId, provider: Provider) {
12
10
  indexTokenAddress,
13
11
  indexTokenABI,
14
12
  provider
15
- ) as any as IndexToken;
13
+ );
16
14
 
17
15
  const totalNFTs = await indexTokenContract.getTokensLength();
18
16
  if (totalNFTs === 0n) {
@@ -29,7 +27,7 @@ async function getNextRandomNFT(chainId: ChainId, provider: Provider) {
29
27
  };
30
28
 
31
29
  return token;
32
- } catch (error: any) {
30
+ } catch (error) {
33
31
  console.error("Error in claimReward:", error);
34
32
  throw error;
35
33
  }
@@ -1,12 +1,10 @@
1
- import { ethers, parseEther, Signer } from "ethers";
2
- import { getContractAddress } from "../getContractAddress";
1
+ import { ethers, parseEther } from "ethers";
2
+ import getContractAddress from "../getContractAddress";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { IndexToken } from "../../typechain-types";
6
4
  import getNextRandomNFT from "./getNextRandomNFT";
7
5
  import getBalance from "../../wallet/assets/getBalance";
8
6
 
9
- async function redeemNFT(chainId: ChainId, signer: Signer) {
7
+ async function redeemNFT(chainId, signer) {
10
8
  try {
11
9
  const indexTokenAddress = getContractAddress(chainId, "indextoken");
12
10
  const indexTokenABI = getABI("indextoken");
@@ -14,7 +12,7 @@ async function redeemNFT(chainId: ChainId, signer: Signer) {
14
12
  indexTokenAddress,
15
13
  indexTokenABI,
16
14
  signer
17
- ) as any as IndexToken;
15
+ );
18
16
 
19
17
  const redemptionToken = await getNextRandomNFT(chainId, signer.provider);
20
18
  if (redemptionToken === null) {
@@ -56,7 +54,7 @@ async function redeemNFT(chainId: ChainId, signer: Signer) {
56
54
  console.log(`Transaction hash: ${receipt?.hash}`);
57
55
 
58
56
  return receipt;
59
- } catch (error: any) {
57
+ } catch (error) {
60
58
  console.error("Error in redeemNFT:", error);
61
59
  throw error;
62
60
  }
@@ -1,20 +1,18 @@
1
- import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../utils/contracts";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { AuctionFactory } from "../../typechain-types";
6
4
 
7
5
  async function createAuction(
8
- chainId: ChainId,
9
- zenoAddress: string,
10
- usdcAddress: string,
11
- businessAddress: string,
12
- auctionStartTime: bigint,
13
- auctionEndTime: bigint,
14
- startingPrice: bigint,
15
- reservePrice: bigint,
16
- totalZenoAllocated: bigint,
17
- signer: Signer
6
+ chainId,
7
+ zenoAddress,
8
+ usdcAddress,
9
+ businessAddress,
10
+ auctionStartTime,
11
+ auctionEndTime,
12
+ startingPrice,
13
+ reservePrice,
14
+ totalZenoAllocated,
15
+ signer
18
16
  ) {
19
17
  if (!signer) {
20
18
  throw new Error("Wallet not connected");
@@ -28,7 +26,7 @@ async function createAuction(
28
26
  auctionFactoryAddress,
29
27
  auctionFactoryABI,
30
28
  signer
31
- ) as any as AuctionFactory;
29
+ );
32
30
 
33
31
  const tx = await auctionFactoryContract.createAuction(
34
32
  zenoAddress,
@@ -48,7 +46,7 @@ async function createAuction(
48
46
  );
49
47
 
50
48
  console.log(`Zeno auction created at address: ${auctionAddress}`);
51
- } catch (error: any) {
49
+ } catch (error) {
52
50
  console.error("Error creating zeno auction:", error);
53
51
  throw new Error(`Failed to create zeno auction: ${error.message}`);
54
52
  }
@@ -1,14 +1,12 @@
1
- import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../utils/contracts";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { ZENOFactory } from "../../typechain-types";
6
4
 
7
5
  async function createZeno(
8
- chainId: ChainId,
9
- usdcAddress: string,
10
- maturityDate: string,
11
- signer: Signer
6
+ chainId,
7
+ usdcAddress,
8
+ maturityDate,
9
+ signer
12
10
  ) {
13
11
  if (!signer) {
14
12
  throw new Error("Wallet not connected");
@@ -22,7 +20,7 @@ async function createZeno(
22
20
  zenoFactoryAddress,
23
21
  zenoFactoryABI,
24
22
  signer
25
- ) as any as ZENOFactory;
23
+ );
26
24
 
27
25
  const tx = await zenoFactoryContract.createZENOContract(
28
26
  usdcAddress,
@@ -38,7 +36,7 @@ async function createZeno(
38
36
  console.log(`Zeno created at address: ${zenoAddress}`);
39
37
 
40
38
  return zenoAddress;
41
- } catch (error: any) {
39
+ } catch (error) {
42
40
  console.error("Error creating zeno:", error);
43
41
  throw new Error(`Failed to create zeno: ${error.message}`);
44
42
  }
@@ -1,10 +1,8 @@
1
- import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../utils/contracts";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { AuctionFactory } from "../../typechain-types";
6
4
 
7
- async function getAuctions(chainId: ChainId, signer: Signer) {
5
+ async function getAuctions(chainId, signer) {
8
6
  if (!signer) {
9
7
  throw new Error("Wallet not connected");
10
8
  }
@@ -17,7 +15,7 @@ async function getAuctions(chainId: ChainId, signer: Signer) {
17
15
  auctionFactoryAddress,
18
16
  auctionFactoryABI,
19
17
  signer
20
- ) as any as AuctionFactory;
18
+ );
21
19
 
22
20
  const auctionsCount = await auctionFactoryContract.getAuctionCount();
23
21
  const auctions = [];
@@ -29,7 +27,7 @@ async function getAuctions(chainId: ChainId, signer: Signer) {
29
27
 
30
28
  console.log(`Auctions: ${auctions}`);
31
29
  return auctions;
32
- } catch (error: any) {
30
+ } catch (error) {
33
31
  console.error("Error getting auctions:", error);
34
32
  throw new Error(`Failed to get auctions: ${error.message}`);
35
33
  }
@@ -1,10 +1,8 @@
1
- import { ethers, Signer } from "ethers";
2
- import { getContractAddress } from "../../utils/contracts";
1
+ import { ethers } from "ethers";
2
+ import getContractAddress from "../../utils/contracts";
3
3
  import { getABI } from "../../utils/artifacts";
4
- import { ChainId } from "../../configs/chains/index";
5
- import { ZENO, ZENOFactory } from "../../typechain-types";
6
4
 
7
- async function getZenos(chainId: ChainId, signer: Signer) {
5
+ async function getZenos(chainId, signer) {
8
6
  if (!signer) {
9
7
  throw new Error("Wallet not connected");
10
8
  }
@@ -17,7 +15,7 @@ async function getZenos(chainId: ChainId, signer: Signer) {
17
15
  zenoFactoryAddress,
18
16
  zenoFactoryABI,
19
17
  signer
20
- ) as any as ZENOFactory;
18
+ );
21
19
 
22
20
  const zenosCount = await zenoFactoryContract.getZENOCount();
23
21
  const zenos = [];
@@ -29,7 +27,7 @@ async function getZenos(chainId: ChainId, signer: Signer) {
29
27
 
30
28
  console.log(`Zenos: ${zenos}`);
31
29
  return zenos;
32
- } catch (error: any) {
30
+ } catch (error) {
33
31
  console.error("Error getting zenos:", error);
34
32
  throw new Error(`Failed to get zenos: ${error.message}`);
35
33
  }