@raac/rpc 1.0.1-beta.1 → 1.0.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,132 @@
1
+ {
2
+ "chainId": 11155111,
3
+ "name": "sepolia",
4
+ "rpcs": ["https://sepolia.infura.io/v3/38126531f7b3458d80e5a822dfbf5854"],
5
+ "nativeCurrency": {
6
+ "name": "ETH",
7
+ "symbol": "ETH",
8
+ "decimals": 18
9
+ },
10
+ "blockExplorer": [
11
+ {
12
+ "name": "Etherscan",
13
+ "url": "https://sepolia.etherscan.io"
14
+ }
15
+ ],
16
+ "contracts": {
17
+ "raachouseprices": {
18
+ "id": "raachouseprices",
19
+ "name": "RAAC House Prices",
20
+ "contract": "0xA151fE9b3F225Ed575D0775c3Db096F14Ead5A0c"
21
+ },
22
+ "raacprimerateoracle": {
23
+ "id": "raacprimerateoracle",
24
+ "name": "RAAC Prime Rate Oracle",
25
+ "contract": "0xB710417257e2bcf66759149812e9B5dA97cEcaFF"
26
+ },
27
+ "auctionfactory": {
28
+ "id": "auctionfactory",
29
+ "name": "Auction Factory",
30
+ "contract": "0xC644A84734A7329eE46d3B6704746179d272f990"
31
+ },
32
+ "zenofactory": {
33
+ "id": "zenofactory",
34
+ "name": "Zeno Factory",
35
+ "contract": "0xa9eE59A113bCB4B2CC10f802D1efF0Bae1Ab91D2"
36
+ },
37
+ "raacminter": {
38
+ "id": "raacminter",
39
+ "name": "RAAC Minter",
40
+ "contract": "0xC9D00720F535dBDBf94472066A3fBba05471aA1f"
41
+ },
42
+ "feecollector": {
43
+ "id": "feecollector",
44
+ "name": "Fee Collector",
45
+ "contract": "0x0a4c1755e9d76cdE0361EB6cDF77824cb06C8a98"
46
+ },
47
+ "treasury": {
48
+ "id": "treasury",
49
+ "name": "Treasury",
50
+ "contract": "0xEaA6082460b2a1Cb2059551A5e368d7bB410D94c"
51
+ },
52
+ "repairfund": {
53
+ "id": "repairfund",
54
+ "name": "Repair Fund",
55
+ "contract": "0x39184F690a71C2978Af392caE86853006D4df97b"
56
+ },
57
+ "releaseorchestrator": {
58
+ "id": "releaseorchestrator",
59
+ "name": "Release Orchestrator",
60
+ "contract": "0x3758d904c69d2C56b89f4b5BbD2c1B1D74773830"
61
+ }
62
+ },
63
+ "pools": {
64
+ "stabilitypool": {
65
+ "id": "stabilitypool",
66
+ "name": "Stability Pool",
67
+ "contract": "0xCDc21F23A946Ab63bdF941677AE19dC5aBdD5011"
68
+ },
69
+ "lendingpool": {
70
+ "id": "lendingpool",
71
+ "name": "Lending Pool",
72
+ "contract": "0x98981d5Ae694d8a63d008c1763716ae26e36A9A7"
73
+ }
74
+ },
75
+ "nfts": {
76
+ "raacnft": {
77
+ "id": "raacnft",
78
+ "name": "RAAC NFT",
79
+ "contract": "0xc986D2750327EA6454d16cE2cD00BA62421dd0bC"
80
+ }
81
+ },
82
+ "assets": {
83
+ "eth": {
84
+ "id": "eth",
85
+ "name": "ETH",
86
+ "decimals": 18,
87
+ "contract": "0x0000000000000000000000000000000000000000"
88
+ },
89
+ "crvusd": {
90
+ "id": "crvusd",
91
+ "name": "CRVUSD",
92
+ "decimals": 18,
93
+ "contract": "0x0eeFb2Edd6865fdDA929dDAEB87701C34CE6B1A3"
94
+ },
95
+ "rtoken": {
96
+ "id": "rtoken",
97
+ "name": "RToken",
98
+ "decimals": 18,
99
+ "contract": "0x9c0Aae91BeA71737EE802cb29EAA15a279cE58E6"
100
+ },
101
+ "detoken": {
102
+ "id": "detoken",
103
+ "name": "DEToken",
104
+ "decimals": 18,
105
+ "contract": "0x8F499A9303e90a3Df10D6B3C435f78B6b6c0b503"
106
+ },
107
+ "raactoken": {
108
+ "id": "raactoken",
109
+ "name": "RAAC",
110
+ "decimals": 18,
111
+ "contract": "0x1503F1fE0c451214D9555F524E12984858202cC6"
112
+ },
113
+ "veraac": {
114
+ "id": "veraac",
115
+ "name": "VERAAC",
116
+ "decimals": 18,
117
+ "contract": "0x2a2d358cdC342f58911Fb8d569E6aA66f564e0D2"
118
+ },
119
+ "debttoken": {
120
+ "id": "debttoken",
121
+ "name": "Debt Token",
122
+ "decimals": 18,
123
+ "contract": "0xf6e002A1E60955d006C5EC1c4Eb74677B73Fba13"
124
+ },
125
+ "indextoken": {
126
+ "id": "indextoken",
127
+ "name": "Index Token",
128
+ "decimals": 18,
129
+ "contract": "0x3A663C401AdF767d710C7f0133DF40eA18F24863"
130
+ }
131
+ }
132
+ }
@@ -7,9 +7,11 @@ exports.configs = void 0;
7
7
  // @ts-ignore
8
8
  const _8453_json_1 = __importDefault(require("./8453.json")); // assert { type: "json" };
9
9
  const _17000_json_1 = __importDefault(require("./17000.json")); // assert { type: "json" };
10
+ const _11155111_json_1 = __importDefault(require("./11155111.json")); // assert { type: "json" };
10
11
  const chains = {
11
12
  8453: _8453_json_1.default,
12
13
  17000: _17000_json_1.default, // the interface is the same for all the chains, so taking this
14
+ 11155111: _11155111_json_1.default,
13
15
  };
14
16
  exports.default = chains;
15
17
  exports.configs = chains;
@@ -5,9 +5,14 @@ const estimateGasPrice = async (signer) => {
5
5
  const provider = signer.provider;
6
6
  try {
7
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;
8
13
  return {
9
- maxFeePerGas: feeData.maxFeePerGas,
10
- maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
14
+ maxFeePerGas,
15
+ maxPriorityFeePerGas,
11
16
  };
12
17
  }
13
18
  catch (error) {
@@ -18,7 +18,7 @@ async function withdrawFromLendingPool(chainId, amount, signer) {
18
18
  const amountInWei = ethers_1.ethers.parseEther(amount.toString());
19
19
  const { maxFeePerGas } = await (0, estimateGasPrice_1.default)(signer);
20
20
  const userBalance = await rTokenContract.balanceOf(await signer.getAddress());
21
- if (userBalance < amount) {
21
+ if (userBalance < parseFloat(amount)) {
22
22
  throw new Error(`Insufficient rToken balance. Available: ${ethers_1.ethers.formatEther(userBalance)}, Requested: ${ethers_1.ethers.formatEther(amount)}`);
23
23
  }
24
24
  const approveTx = await rTokenContract.approve(lendingPoolAddress, amountInWei);
@@ -85,7 +85,7 @@ async function setup() {
85
85
  const tx = await deTokenContract.setStabilityPool(stabilityPoolAddress);
86
86
  await tx.wait();
87
87
  console.log("Stability pool set to", stabilityPoolAddress);
88
- // fulfillRequest();
88
+ fulfillRequest();
89
89
  }
90
90
  const execute = async () => {
91
91
  const provider = await getProvider();
@@ -132,25 +132,7 @@ const fulfillRequest = async () => {
132
132
  const redemptionToken = await rpc.contracts.indexToken.getNextRandomNFT(chainId, provider);
133
133
  console.log("Redemption token", redemptionToken);
134
134
  };
135
- const transfer = async () => {
136
- const provider = await getProvider();
137
- const signer = await createWallet(TEST_MNEMONIC, provider);
138
- const rpc = new RPCLibrary_1.default();
139
- rpc.address = signer.address;
140
- rpc.provider = provider;
141
- rpc.chainId = chainId;
142
- const walletToTransferCRVUSD = "0xC02f7FFd1791fFf16585ECe5658a938983BAF9dA";
143
- // await rpc.wallet.assets.approveAsset(
144
- // chainId,
145
- // "crvusd",
146
- // "1000000",
147
- // walletToTransferCRVUSD,
148
- // signer
149
- // );
150
- await rpc.wallet.assets.transferAsset(chainId, "crvusd", 3000000n, signer.address, walletToTransferCRVUSD, signer);
151
- };
152
135
  // execute();
153
136
  // setup();
154
137
  fulfillRequest();
155
- // updateNFTPrice("1", "100000");
156
- // transfer();
138
+ // updateNFTPrice("7", "1650000");
@@ -1,12 +1,14 @@
1
- import { Chain8453 } from "./chain";
1
+ import { Chain8453, Chain11155111 } from "./chain";
2
2
  declare const chains: {
3
3
  8453: Chain8453;
4
4
  17000: Chain8453;
5
+ 11155111: Chain11155111;
5
6
  };
6
7
  export default chains;
7
8
  export declare const configs: {
8
9
  8453: Chain8453;
9
10
  17000: Chain8453;
11
+ 11155111: Chain11155111;
10
12
  };
11
13
  export type Configs = typeof chains;
12
14
  export type ConfigKeys = keyof Configs;
@@ -2,6 +2,7 @@ import { ChainId } from "./chains/index";
2
2
  declare function getChainsConfig(): {
3
3
  8453: import("./chains/chain").Chain8453;
4
4
  17000: import("./chains/chain").Chain8453;
5
+ 11155111: import("./chains/chain").Chain11155111;
5
6
  };
6
7
  declare function setChainConfig(chainId: ChainId, config: any): void;
7
8
  declare function getChainConfig(chainId: ChainId): any;
@@ -1,4 +1,4 @@
1
1
  import { ethers, Signer } from "ethers";
2
2
  import { ChainId } from "../../configs/chains";
3
- declare function withdrawFromLendingPool(chainId: ChainId, amount: bigint, signer: Signer): Promise<ethers.ContractTransactionReceipt>;
3
+ declare function withdrawFromLendingPool(chainId: ChainId, amount: string, signer: Signer): Promise<ethers.ContractTransactionReceipt>;
4
4
  export default withdrawFromLendingPool;
@@ -4,6 +4,7 @@ import { ethers, Provider } from "ethers";
4
4
  export declare const getConfigs: () => {
5
5
  8453: import("../configs/chains/chain").Chain8453;
6
6
  17000: import("../configs/chains/chain").Chain8453;
7
+ 11155111: import("../configs/chains/chain").Chain11155111;
7
8
  };
8
9
  export declare const setOverrideConfig: (chainId: ChainId, newConfig: any) => void;
9
10
  export declare const getConfig: (chainId: ChainId) => any;
@@ -17,6 +18,7 @@ declare const _default: {
17
18
  getConfigs: () => {
18
19
  8453: import("../configs/chains/chain").Chain8453;
19
20
  17000: import("../configs/chains/chain").Chain8453;
21
+ 11155111: import("../configs/chains/chain").Chain11155111;
20
22
  };
21
23
  };
22
24
  export default _default;
@@ -12,7 +12,7 @@ async function getAsset(chainId, assetId, address, provider) {
12
12
  const owner = address;
13
13
  try {
14
14
  const balance = await this.getBalance(chainId, assetId, owner, provider);
15
- response.balance = parseFloat(balance).toString();
15
+ response.balance = balance;
16
16
  }
17
17
  catch (error) {
18
18
  console.log(`Error getting balance: ${error}`);
@@ -13,8 +13,8 @@ async function getBalance(chainId, assetId, address, provider) {
13
13
  const contractAddress = (0, contracts_1.getContractAddress)(chainId, assetId);
14
14
  const contract = new ethers_1.ethers.Contract(contractAddress, BALANCE_OF_ABI, provider);
15
15
  const balance = await contract.balanceOf(address);
16
- const parsedBalance = parseFloat(ethers_1.ethers.formatEther(balance));
17
- return parsedBalance.toString();
16
+ const parsedBalance = ethers_1.ethers.formatEther(balance);
17
+ return parsedBalance;
18
18
  }
19
19
  catch (error) {
20
20
  console.error(`Error getting balance for asset ${assetId}:`, error);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@raac/rpc",
3
- "version": "1.0.1-beta.1",
3
+ "version": "1.0.1-beta.2",
4
4
  "description": "RPC Library for RAAC ",
5
5
  "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
6
+ "types": "dist/types/index.d.ts",
7
7
  "files": [
8
8
  "dist"
9
9
  ],