@raac/rpc 1.1.0-beta.69 → 1.1.0-beta.70

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.
@@ -2,13 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ethers_1 = require("ethers");
4
4
  const _helpers_1 = require("./_helpers");
5
+ const getAdapterAddress_1 = require("./getAdapterAddress");
5
6
  async function redeemNFTFromRWAVault(chainId, adapter, tokenId, maxSharesBurn, signer) {
6
7
  if (!signer) {
7
8
  throw new Error("Wallet not connected");
8
9
  }
9
10
  try {
10
11
  const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, signer);
11
- const tx = await rwaVaultContract.redeemNFT(adapter, tokenId, ethers_1.ethers.parseEther(maxSharesBurn));
12
+ const address = (0, getAdapterAddress_1.getAdapterAddress)(chainId, adapter).address;
13
+ if (!address) {
14
+ throw new Error(`Adapter ${adapter} not found`);
15
+ }
16
+ const tx = await rwaVaultContract.redeemNFT(address, tokenId, ethers_1.ethers.parseEther(maxSharesBurn));
12
17
  console.log(`Redeem NFT transaction sent to RWA Vault:`, tx.hash);
13
18
  const receipt = await tx.wait();
14
19
  console.log(`Redeemed NFT from RWA Vault successfully:`, receipt?.hash);
@@ -11,7 +11,7 @@ const contracts_1 = require("../utils/contracts");
11
11
  const artifacts_1 = require("../utils/artifacts");
12
12
  const _helpers_1 = require("../pools/rwaVault/_helpers");
13
13
  const ethers5_1 = require("ethers5");
14
- const chainId = 8453;
14
+ const chainId = 11155111;
15
15
  const config = chains_1.default[chainId];
16
16
  const TEST_MNEMONIC = process.env.TEST_MNEMONIC;
17
17
  const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY;
@@ -69,14 +69,20 @@ async function setup() {
69
69
  const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
70
70
  const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
71
71
  const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, signer);
72
+ const RWAVaultAddress = (0, contracts_1.getContractAddress)(chainId, "rwavault");
73
+ const RWAVaultABI = (0, artifacts_1.getABI)("rwavault");
74
+ const RWAVaultContract = new ethers_1.ethers.Contract(RWAVaultAddress, RWAVaultABI, signer);
72
75
  // const secretsReference = await encryptSecrets(chainId, {
73
76
  // apiKey: process.env.FRED_API_KEY as string,
74
77
  // }, "encryptedFunctionsPrimeRateSecrets.json", signerV5);
75
78
  // console.log(secretsReference);
76
- // return;
77
79
  await (await raacNFTContract.setAllowMinting(true)).wait();
80
+ await (await raacNFTContract.setPriceStalenessThreshold(7 * 24 * 60 * 60)).wait();
78
81
  return;
79
- await rpc.contracts.housePrices.setOracle(chainId, signer.address, signer);
82
+ // return;
83
+ // await (await raacNFTContract.setAllowMinting(true)).wait();
84
+ // return;
85
+ // await rpc.contracts.housePrices.setOracle(chainId, signer.address, signer);
80
86
  // const encryptedURL = await encryptSecretURLs(chainId, ["https://emerald-many-grasshopper-318.mypinata.cloud/ipfs/bafkreifvuyg7rsfx2wbyeulc267mvg5nwak2ggaxnr723zbekuzycjiysa"], signerV5);
81
87
  // console.log(encryptedURL);
82
88
  // const secretReference = await generateSecretReference(chainId, {
@@ -100,29 +106,35 @@ async function setup() {
100
106
  // let tx = await StabilityPoolContract.setLiquidationVaultTokenSplit(2_50, 2_50, 90_00, 5_00)
101
107
  // await tx.wait();
102
108
  // Add funds in the Mock Liquidity Pool
109
+ // await (await RWAVaultContract.registerDepositableAdapter(await rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter").address)).wait();
110
+ // return;
111
+ const MockLiquidityPoolAddress = "0x455Ad6413DeeD5A2B3AC9dc8826e5a58A8c5181D";
112
+ const MockLiquidityPoolABI = ["function add_liquidity(uint256[2] amounts, uint256 min_mint_amount, address receiver) external"];
113
+ const MockLiquidityPoolContract = new ethers_1.ethers.Contract(MockLiquidityPoolAddress, MockLiquidityPoolABI, signer);
103
114
  // mint 10 million in crvusd
104
- // console.log("Minting 10 million in crvusd");
115
+ console.log("Minting 10 million in crvusd");
105
116
  // await rpc.wallet.assets.mintAsset(chainId, "crvusd", 10000000n, signer.address, signer)
106
- // // deposit 5 million in the RWA Vault
107
- // console.log("Depositing 5 million in the RWA Vault");
117
+ // deposit 5 million in the RWA Vault
118
+ console.log("Depositing 5 million in the RWA Vault");
108
119
  // await rpc.wallet.assets.approveAsset(chainId, "crvusd", await rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter").address, "5000000", signer);
109
- // const data = new ethers.AbiCoder().encode(["uint256"], [ ethers.parseEther("5000000") ])
110
- // await rpc.pools.rwaVault.depositToRWAVault(chainId, "crvusdadapter", data, signer.address, signer)
111
- // // deposit 5 million in the Mock Liquidity Pool
112
- // console.log("Depositing 5 million in the Mock Liquidity Pool");
113
- // await rpc.wallet.assets.approveAsset(chainId, "crvusd", MockLiquidityPoolAddress, "5000000", signer);
114
- // const indextokenBalance = (await rpc.wallet.assets.getBalance(chainId, "rwaindextoken", signer.address, provider)).balance
115
- // await rpc.wallet.assets.approveAsset(chainId, "rwaindextoken", MockLiquidityPoolAddress, indextokenBalance, signer);
116
- // await (await MockLiquidityPoolContract.add_liquidity([ethers.parseEther("5000000"), ethers.parseEther(indextokenBalance.toString())], 0)).wait();
117
- // // check the liquidity in the pools
118
- // console.log("Checking the liquidity in the pools");
119
- // const liquidity = await MockLiquidityPoolContract.getTotalLiquidity(await rpc.contracts.getContractAddress(chainId, "rwaindextoken"))
120
- // console.log("Liquidity in the Mock Liquidity Pool", liquidity);
120
+ const d1 = new ethers_1.ethers.AbiCoder().encode(["uint256"], [ethers_1.ethers.parseEther("5000000")]);
121
+ await rpc.pools.rwaVault.depositToRWAVault(chainId, "crvusdadapter", d1, signer.address, "0", signer);
122
+ // deposit 5 million in the Mock Liquidity Pool
123
+ console.log("Depositing 5 million in the Mock Liquidity Pool");
124
+ await rpc.wallet.assets.approveAsset(chainId, "crvusd", MockLiquidityPoolAddress, "5000000", signer);
125
+ const indextokenBalance = (await rpc.wallet.assets.getBalance(chainId, "rwaindextoken", signer.address, provider)).balance;
126
+ await rpc.wallet.assets.approveAsset(chainId, "rwaindextoken", MockLiquidityPoolAddress, indextokenBalance, signer);
127
+ await (await MockLiquidityPoolContract.add_liquidity([ethers_1.ethers.parseEther("5000000"), ethers_1.ethers.parseEther(indextokenBalance.toString())], 0, signer.address)).wait();
128
+ // check the liquidity in the pools
129
+ console.log("Checking the liquidity in the pools");
130
+ const liquidity = await MockLiquidityPoolContract.getTotalLiquidity(await rpc.contracts.getContractAddress(chainId, "rwaindextoken"));
131
+ console.log("Liquidity in the Mock Liquidity Pool", liquidity);
121
132
  // mint the current user 5 million irAAC
122
- // console.log("Minting 5 million irAAC");
123
- // await rpc.wallet.assets.approveAsset(chainId, "crvusd", await rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter").address, "5000000", signer);
124
- // const data = new ethers.AbiCoder().encode(["uint256"], [ ethers.parseEther("5000000") ])
125
- // await rpc.pools.rwaVault.depositToRWAVault(chainId, "crvusdadapter", data, signer.address, signer)
133
+ console.log("Minting 5 million irAAC");
134
+ await rpc.wallet.assets.approveAsset(chainId, "crvusd", await rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter").address, "5000000", signer);
135
+ const data = new ethers_1.ethers.AbiCoder().encode(["uint256"], [ethers_1.ethers.parseEther("5000000")]);
136
+ await rpc.pools.rwaVault.depositToRWAVault(chainId, "crvusdadapter", data, signer.address, "0", signer);
137
+ return;
126
138
  /// END OF ADD FUNDS IN THE MOCK LIQUIDITY POOL
127
139
  // // // send myself some CRVUSD
128
140
  // await rpc.wallet.assets.mintAsset(
@@ -134,9 +146,6 @@ async function setup() {
134
146
  // );
135
147
  // set the base uri to instruxi data gateway
136
148
  await rpc.nfts.setBaseUri(chainId, "http://3.86.253.54:3000/v1/properties/", signer);
137
- const RWAVaultAddress = (0, contracts_1.getContractAddress)(chainId, "rwavault");
138
- const RWAVaultABI = (0, artifacts_1.getABI)("rwavault");
139
- const RWAVaultContract = new ethers_1.ethers.Contract(RWAVaultAddress, RWAVaultABI, signer);
140
149
  // // @ts-ignore
141
150
  // if (chainId === 11155111) {
142
151
  // await RWAVaultContract.setVRFConsumer("0x244dC85807D947B2c590DEb1A340B818d5CD59B9")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raac/rpc",
3
- "version": "1.1.0-beta.69",
3
+ "version": "1.1.0-beta.70",
4
4
  "description": "RPC Library for RAAC ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",