@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.
- package/{RPCLibrary.ts → RPCLibrary.js} +7 -121
- package/assets/{getAsset.ts → getAsset.js} +6 -6
- package/assets/{getAssets.ts → getAssets.js} +2 -3
- package/assets/{getSupply.ts → getSupply.js} +5 -7
- package/configs/chains/index.js +13 -0
- package/configs/index.js +17 -0
- package/contracts/feeCollector/{claimRewardFromPool.ts → claimRewardFromPool.js} +4 -10
- package/contracts/{getContract.ts → getContract.js} +5 -6
- package/contracts/{getContractAddress.ts → getContractAddress.js} +4 -6
- package/contracts/housePrices/{getLatestPrice.ts → getLatestPrice.js} +6 -8
- package/contracts/housePrices/{setOracle.ts → setOracle.js} +6 -8
- package/contracts/indexToken/{getNextRandomNFT.ts → getNextRandomNFT.js} +5 -7
- package/contracts/indexToken/{redeemNFT.ts → redeemNFT.js} +5 -7
- package/contracts/zeno/{createAuction.ts → createAuction.js} +14 -16
- package/contracts/zeno/{createZeno.ts → createZeno.js} +8 -10
- package/contracts/zeno/{getAuctions.ts → getAuctions.js} +5 -7
- package/contracts/zeno/{getZenos.ts → getZenos.js} +5 -7
- package/methods/commons/{checkAllowance.ts → checkAllowance.js} +10 -12
- package/methods/commons/{estimateGasPrice.ts → estimateGasPrice.js} +5 -7
- package/minter/{get.ts → get.js} +6 -8
- package/minter/{getApy.ts → getApy.js} +5 -7
- package/minter/{tick.ts → tick.js} +5 -7
- package/nfts/{getAllTokens.ts → getAllTokens.js} +7 -9
- package/nfts/{getBaseUri.ts → getBaseUri.js} +5 -7
- package/nfts/{getHousePrice.ts → getHousePrice.js} +6 -8
- package/nfts/{getMintFeePercentage.ts → getMintFeePercentage.js} +4 -6
- package/nfts/{getMintPrice.ts → getMintPrice.js} +7 -9
- package/nfts/{getTokenURI.ts → getTokenURI.js} +7 -9
- package/nfts/{getTokensByOwner.ts → getTokensByOwner.js} +8 -10
- package/nfts/{getTotalPropertiesCount.ts → getTotalPropertiesCount.js} +5 -7
- package/nfts/{mint.ts → mint.js} +7 -9
- package/nfts/{setBaseUri.ts → setBaseUri.js} +4 -6
- package/nfts/{totalNFTSupply.ts → totalNFTSupply.js} +4 -6
- package/package.json +1 -1
- package/pools/lendingPool/{borrowFromLendingPool.ts → borrowFromLendingPool.js} +8 -10
- package/pools/lendingPool/{borrowFromLendingPoolWithInsurance.ts → borrowFromLendingPoolWithInsurance.js} +8 -10
- package/pools/lendingPool/{calculateInsuranceFee.ts → calculateInsuranceFee.js} +9 -11
- package/pools/lendingPool/{claimReward.ts → claimReward.js} +5 -7
- package/pools/lendingPool/{closeLiquidation.ts → closeLiquidation.js} +7 -9
- package/pools/lendingPool/{depositNFTToLendingPool.ts → depositNFTToLendingPool.js} +6 -8
- package/pools/lendingPool/{depositToLendingPool.ts → depositToLendingPool.js} +6 -8
- package/pools/lendingPool/{getAllUserData.ts → getAllUserData.js} +7 -14
- package/pools/lendingPool/{getEligibleUserDeposits.ts → getEligibleUserDeposits.js} +7 -9
- package/pools/lendingPool/{getHealthFactor.ts → getHealthFactor.js} +8 -10
- package/pools/lendingPool/{getHousePrice.ts → getHousePrice.js} +6 -8
- package/pools/lendingPool/{getLendingPoolInfo.ts → getLendingPoolInfo.js} +23 -31
- package/pools/lendingPool/{getLendingPoolTotalLiquidity.ts → getLendingPoolTotalLiquidity.js} +7 -10
- package/pools/lendingPool/{getPendingReward.ts → getPendingReward.js} +7 -9
- package/pools/lendingPool/{getPositionDebt.ts → getPositionDebt.js} +8 -10
- package/pools/lendingPool/{getPositionScaledDebt.ts → getPositionScaledDebt.js} +8 -10
- package/pools/lendingPool/{getPositionView.ts → getPositionView.js} +9 -11
- package/pools/lendingPool/{getPositionsScaledDebt.ts → getPositionsScaledDebt.js} +7 -9
- package/pools/lendingPool/{getRawUserDepositsInLendingPool.ts → getRawUserDepositsInLendingPool.js} +7 -9
- package/pools/lendingPool/{getUserCollateralValue.ts → getUserCollateralValue.js} +7 -9
- package/pools/lendingPool/{initializeLiquidation.ts → initializeLiquidation.js} +8 -10
- package/pools/lendingPool/{repayToLendingPool.ts → repayToLendingPool.js} +8 -10
- package/pools/lendingPool/{withdrawFromLendingPool.ts → withdrawFromLendingPool.js} +9 -10
- package/pools/lendingPool/{withdrawNFTFromLendingPool.ts → withdrawNFTFromLendingPool.js} +7 -9
- package/pools/stabilityPool/{calculateRAACRewards.ts → calculateRAACRewards.js} +6 -9
- package/pools/stabilityPool/configs/chains/index.js +17 -0
- package/pools/stabilityPool/configs/index.js +43 -0
- package/pools/stabilityPool/{depositNFTToStabilityPool.ts → depositNFTToStabilityPool.js} +6 -9
- package/pools/stabilityPool/{depositToStabilityPool.ts → depositToStabilityPool.js} +6 -8
- package/pools/stabilityPool/{getRawUserDepositsInStabilityPool.ts → getRawUserDepositsInStabilityPool.js} +7 -9
- package/pools/stabilityPool/{getStabilityPoolInfo.ts → getStabilityPoolInfo.js} +10 -12
- package/pools/stabilityPool/{getStabilityPoolTotalDeposits.ts → getStabilityPoolTotalDeposits.js} +6 -8
- package/pools/stabilityPool/methods/commons/estimateGasPrice.js +28 -0
- package/pools/stabilityPool/pools/stabilityPool/withdrawFromStabilityPool.js +34 -0
- package/pools/stabilityPool/utils/artifacts.js +74 -0
- package/pools/stabilityPool/utils/contracts.js +82 -0
- package/pools/stabilityPool/{withdrawFromStabilityPool.ts → withdrawFromStabilityPool.js} +6 -8
- package/ts-to-js.sh +42 -0
- package/utils/{artifacts.ts → artifacts.js} +1 -4
- package/utils/{contracts.ts → contracts.js} +16 -18
- package/wallet/assets/{approveAsset.ts → approveAsset.js} +7 -8
- package/wallet/assets/{burnAsset.ts → burnAsset.js} +7 -9
- package/wallet/assets/{getAllowance.ts → getAllowance.js} +9 -10
- package/wallet/assets/{getAsset.ts → getAsset.js} +6 -7
- package/wallet/assets/{getAssets.ts → getAssets.js} +5 -6
- package/wallet/assets/{getBalance.ts → getBalance.js} +8 -9
- package/wallet/assets/{mintAsset.ts → mintAsset.js} +8 -9
- package/wallet/assets/{transferAsset.ts → transferAsset.js} +10 -11
- package/configs/chains/index.ts +0 -17
- package/configs/index.ts +0 -51
- /package/configs/chains/{chain.d.ts → chain.d.js} +0 -0
- /package/configs/{createConfig.ts → createConfig.js} +0 -0
- /package/contracts/crvUSDToken/{getBalance.ts → getBalance.js} +0 -0
- /package/contracts/crvUSDToken/{getTotalSupply.ts → getTotalSupply.js} +0 -0
- /package/contracts/rcrvUSDToken/{getBalance.ts → getBalance.js} +0 -0
- /package/contracts/rcrvUSDToken/{getTotalSupply.ts → getTotalSupply.js} +0 -0
- /package/{custom-types.d.ts → custom-types.d.js} +0 -0
- /package/{index.ts → index.js} +0 -0
- /package/methods/{approveToken.ts → approveToken.js} +0 -0
- /package/methods/{getAssetBalance.ts → getAssetBalance.js} +0 -0
- /package/methods/{getAssetsBalance.ts → getAssetsBalance.js} +0 -0
- /package/pools/liquidityPool/{getLiquidityPoolInfo.ts → getLiquidityPoolInfo.js} +0 -0
- /package/scripts/{index.ts → index.js} +0 -0
- /package/tests/{test.ts → test.js} +0 -0
- /package/utils/{chain.ts → chain.js} +0 -0
- /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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
9
|
-
assetId
|
|
10
|
-
provider
|
|
8
|
+
chainId,
|
|
9
|
+
assetId,
|
|
10
|
+
provider
|
|
11
11
|
) {
|
|
12
12
|
try {
|
|
13
13
|
const { assets } = getConfig(chainId);
|
|
14
|
-
const asset
|
|
15
|
-
(asset
|
|
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
|
|
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
|
|
5
|
+
async function getAssets(chainId, provider) {
|
|
6
6
|
const { assets } = getConfig(chainId);
|
|
7
|
-
const responses
|
|
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
|
|
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
|
|
8
|
-
assetId
|
|
9
|
-
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
|
|
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;
|
package/configs/index.js
ADDED
|
@@ -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
|
|
9
|
-
poolAddress
|
|
10
|
-
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
|
|
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
|
|
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
|
|
8
|
-
contractName
|
|
9
|
-
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
|
|
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
|
|
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
|
|
13
|
-
contractName
|
|
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
|
-
]
|
|
30
|
+
];
|
|
33
31
|
|
|
34
32
|
let address = null;
|
|
35
33
|
for (const key of lookupKeys) {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { 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
|
|
9
|
-
tokenId
|
|
10
|
-
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
|
-
)
|
|
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
|
|
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
|
|
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
|
|
9
|
-
newOracleAddress
|
|
10
|
-
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
|
-
)
|
|
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
|
|
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
|
|
2
|
-
import
|
|
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
|
|
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
|
-
)
|
|
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
|
|
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
|
|
2
|
-
import
|
|
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
|
|
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
|
-
)
|
|
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
|
|
57
|
+
} catch (error) {
|
|
60
58
|
console.error("Error in redeemNFT:", error);
|
|
61
59
|
throw error;
|
|
62
60
|
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { ethers
|
|
2
|
-
import
|
|
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
|
|
9
|
-
zenoAddress
|
|
10
|
-
usdcAddress
|
|
11
|
-
businessAddress
|
|
12
|
-
auctionStartTime
|
|
13
|
-
auctionEndTime
|
|
14
|
-
startingPrice
|
|
15
|
-
reservePrice
|
|
16
|
-
totalZenoAllocated
|
|
17
|
-
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
|
-
)
|
|
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
|
|
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
|
|
2
|
-
import
|
|
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
|
|
9
|
-
usdcAddress
|
|
10
|
-
maturityDate
|
|
11
|
-
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
|
-
)
|
|
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
|
|
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
|
|
2
|
-
import
|
|
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
|
|
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
|
-
)
|
|
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
|
|
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
|
|
2
|
-
import
|
|
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
|
|
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
|
-
)
|
|
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
|
|
30
|
+
} catch (error) {
|
|
33
31
|
console.error("Error getting zenos:", error);
|
|
34
32
|
throw new Error(`Failed to get zenos: ${error.message}`);
|
|
35
33
|
}
|