@raac/rpc 1.1.0-beta.31 → 1.1.0-beta.33
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/dist/configs/chains/8453.json +5 -5
- package/dist/pools/rwaVault/_helpers.js +2 -3
- package/dist/pools/rwaVault/depositToRWAVault.js +12 -4
- package/dist/pools/rwaVault/getNextRandomNFT.js +1 -1
- package/dist/pools/rwaVault/getRWAVaultInfo.js +2 -5
- package/dist/pools/rwaVault/redeemNFTFromRWAVault.js +1 -1
- package/dist/pools/rwaVault/requestRandomSeed.js +1 -1
- package/dist/scripts/index.js +39 -1
- package/dist/types/RPCLibrary.d.ts +1 -1
- package/dist/types/pools/rwaVault/_helpers.d.ts +2 -2
- package/dist/types/pools/rwaVault/getRWAVaultInfo.d.ts +2 -2
- package/package.json +1 -1
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"raacnft": {
|
|
77
77
|
"id": "raacnft",
|
|
78
78
|
"name": "RAAC NFT",
|
|
79
|
-
"contract": "
|
|
79
|
+
"contract": "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8"
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"assets": {
|
|
@@ -134,13 +134,13 @@
|
|
|
134
134
|
"raacnftadapter": {
|
|
135
135
|
"id": "raacnftadapter",
|
|
136
136
|
"name": "RAAC NFT Adapter",
|
|
137
|
-
"contract": "
|
|
137
|
+
"contract": "0xf5059a5D33d5853360D16C683c16e67980206f36",
|
|
138
138
|
"type": "ERC721"
|
|
139
139
|
},
|
|
140
140
|
"rwaindextokenadapter": {
|
|
141
141
|
"id": "rwaindextokenadapter",
|
|
142
142
|
"name": "RWA Index Token",
|
|
143
|
-
"contract": "
|
|
143
|
+
"contract": "0x851356ae760d987E095750cCeb3bC6014560891C",
|
|
144
144
|
"type": "ERC20"
|
|
145
145
|
}
|
|
146
146
|
},
|
|
@@ -148,13 +148,13 @@
|
|
|
148
148
|
"raacnftadapter": {
|
|
149
149
|
"id": "raacnftadapter",
|
|
150
150
|
"name": "RAAC NFT Adapter",
|
|
151
|
-
"contract": "
|
|
151
|
+
"contract": "0x70e0bA845a1A0F2DA3359C97E0285013525FFC49",
|
|
152
152
|
"type": "ERC721"
|
|
153
153
|
},
|
|
154
154
|
"crvusdadapter": {
|
|
155
155
|
"id": "crvusdadapter",
|
|
156
156
|
"name": "CRVUSD Adapter",
|
|
157
|
-
"contract": "
|
|
157
|
+
"contract": "0x67d269191c92Caf3cD7723F116c85e6E9bf55933",
|
|
158
158
|
"type": "ERC20"
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -33,9 +33,8 @@ function getRWAVaultAdapterByAddress(chainId, address) {
|
|
|
33
33
|
throw new Error("Adapter not found in config.");
|
|
34
34
|
return adaptersConfig.rwavault[matchKey];
|
|
35
35
|
}
|
|
36
|
-
async function getRWAVaultContract(chainId) {
|
|
36
|
+
async function getRWAVaultContract(chainId, provider_signer) {
|
|
37
37
|
const rwaVaultAddress = (0, getContractAddress_1.default)(chainId, "rwavault");
|
|
38
38
|
const rwaVaultABI = (0, artifacts_1.getABI)("rwavault");
|
|
39
|
-
|
|
40
|
-
return new ethers_1.ethers.Contract(rwaVaultAddress, rwaVaultABI, provider);
|
|
39
|
+
return new ethers_1.ethers.Contract(rwaVaultAddress, rwaVaultABI, provider_signer);
|
|
41
40
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const _helpers_1 = require("./_helpers");
|
|
7
|
+
const getAdapterAddress_1 = require("./getAdapterAddress");
|
|
8
|
+
const getAllowance_1 = __importDefault(require("../../wallet/assets/getAllowance"));
|
|
4
9
|
async function depositToRWAVault(chainId, adapter, data, receiver, signer) {
|
|
5
10
|
if (!signer) {
|
|
6
11
|
throw new Error("Wallet not connected");
|
|
7
12
|
}
|
|
8
13
|
try {
|
|
9
|
-
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, signer);
|
|
15
|
+
const adapterAddress = await (0, getAdapterAddress_1.getAdapterAddress)(chainId, adapter);
|
|
16
|
+
console.log("adapterAddress", adapterAddress.address);
|
|
17
|
+
console.log("data", data);
|
|
18
|
+
console.log("receiver", receiver);
|
|
19
|
+
console.log(await (0, getAllowance_1.default)(chainId, "crvusd", await signer.getAddress(), adapterAddress.address, signer.provider));
|
|
20
|
+
const tx = await rwaVaultContract.depositAsset(adapterAddress.address, data, receiver);
|
|
13
21
|
console.log(`Deposit transaction sent to RWA Vault:`, tx.hash);
|
|
14
22
|
const receipt = await tx.wait();
|
|
15
23
|
console.log(`Deposited to RWA Vault successfully:`, receipt?.hash);
|
|
@@ -6,7 +6,7 @@ async function getNextRandomNFT(chainId, signer) {
|
|
|
6
6
|
throw new Error("Wallet not connected");
|
|
7
7
|
}
|
|
8
8
|
try {
|
|
9
|
-
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId);
|
|
9
|
+
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, signer);
|
|
10
10
|
const [adapter, tokenId] = await rwaVaultContract.getNextRandomNFT();
|
|
11
11
|
return {
|
|
12
12
|
adapter,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const _helpers_1 = require("./_helpers");
|
|
4
|
-
async function getRWAVaultInfo(chainId,
|
|
5
|
-
if (!signer) {
|
|
6
|
-
throw new Error("Wallet not connected");
|
|
7
|
-
}
|
|
4
|
+
async function getRWAVaultInfo(chainId, provider) {
|
|
8
5
|
try {
|
|
9
|
-
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId);
|
|
6
|
+
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, provider);
|
|
10
7
|
const [totalAssets, pricePerShare, vaultToken, underlyingAssetToken, stabilityPool, vrfConsumer, indexTokenMintingFee, feeCollector, vrfRequestDelay, allowVRFRequest, llamaTemple, llamaPerkDiscount, llamaPerkMultiplier, llamaPerkClassName] = await Promise.all([
|
|
11
8
|
rwaVaultContract.totalAssets(),
|
|
12
9
|
rwaVaultContract.pricePerShare(),
|
|
@@ -6,7 +6,7 @@ async function redeemNFTFromRWAVault(chainId, signer) {
|
|
|
6
6
|
throw new Error("Wallet not connected");
|
|
7
7
|
}
|
|
8
8
|
try {
|
|
9
|
-
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId);
|
|
9
|
+
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, signer);
|
|
10
10
|
const tx = await rwaVaultContract.redeemNFT({
|
|
11
11
|
nonce: await signer.getNonce(),
|
|
12
12
|
});
|
|
@@ -6,7 +6,7 @@ async function requestRandomSeed(chainId, signer) {
|
|
|
6
6
|
throw new Error("Wallet not connected");
|
|
7
7
|
}
|
|
8
8
|
try {
|
|
9
|
-
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId);
|
|
9
|
+
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, signer);
|
|
10
10
|
const tx = await rwaVaultContract.requestRandomSeed({
|
|
11
11
|
nonce: await signer.getNonce(),
|
|
12
12
|
});
|
package/dist/scripts/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const chains_1 = __importDefault(require("../configs/chains"));
|
|
|
9
9
|
const RPCLibrary_1 = __importDefault(require("../RPCLibrary"));
|
|
10
10
|
const contracts_1 = require("../utils/contracts");
|
|
11
11
|
const artifacts_1 = require("../utils/artifacts");
|
|
12
|
+
const _helpers_1 = require("../pools/rwaVault/_helpers");
|
|
12
13
|
const chainId = 8453;
|
|
13
14
|
const config = chains_1.default[chainId];
|
|
14
15
|
const TEST_MNEMONIC = process.env.TEST_MNEMONIC;
|
|
@@ -116,7 +117,44 @@ const execute = async () => {
|
|
|
116
117
|
rpc.address = signer.address;
|
|
117
118
|
rpc.provider = provider;
|
|
118
119
|
rpc.chainId = chainId;
|
|
119
|
-
|
|
120
|
+
// await rpc.wallet.assets.mintAsset(
|
|
121
|
+
// chainId,
|
|
122
|
+
// "crvusd",
|
|
123
|
+
// 10000000n,
|
|
124
|
+
// signer.address,
|
|
125
|
+
// signer
|
|
126
|
+
// );
|
|
127
|
+
// Minting Fee collection
|
|
128
|
+
const feeCollectorAddress = (0, contracts_1.getContractAddress)(chainId, "feecollector");
|
|
129
|
+
const feeCollectorABI = (0, artifacts_1.getABI)("feecollector");
|
|
130
|
+
const feeCollectorContract = new ethers_1.ethers.Contract(feeCollectorAddress, feeCollectorABI, signer);
|
|
131
|
+
const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, signer);
|
|
132
|
+
const erc20AdapterAddress = rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter").address;
|
|
133
|
+
const abi = (0, artifacts_1.getABI)("erc20vaultadapter");
|
|
134
|
+
const erc20AdapterContract = new ethers_1.ethers.Contract(erc20AdapterAddress, abi, signer);
|
|
135
|
+
const crvusdAddress = await erc20AdapterContract.getAssetToken();
|
|
136
|
+
const crvusdABI = (0, artifacts_1.getABI)("crvusd");
|
|
137
|
+
const crvusdContract = new ethers_1.ethers.Contract(crvusdAddress, crvusdABI, signer);
|
|
138
|
+
const vaultTokenAddress = await rwaVaultContract.vaultToken();
|
|
139
|
+
const vaultTokenABI = (0, artifacts_1.getABI)("rwaindextoken");
|
|
140
|
+
const vaultTokenContract = new ethers_1.ethers.Contract(vaultTokenAddress, vaultTokenABI, signer);
|
|
141
|
+
// console.log("CRVUSD address", await getContractAddress(chainId, "crvusd"));
|
|
142
|
+
// console.log("CRVUSD address", await erc20AdapterContract.getAssetToken());
|
|
143
|
+
// console.log("Total value", await erc20AdapterContract.totalValue());
|
|
144
|
+
// console.log("Price oracle", await erc20AdapterContract.priceOracle());
|
|
145
|
+
// await feeCollectorContract.addClaimableToken(getContractAddress(chainId, "rwaindextoken"));
|
|
146
|
+
// await feeCollectorContract.addFeeType(MINT_FEE, 10000, 0, 0, 0, 0, 0);
|
|
147
|
+
// console.log(await rwaVaultContract.supportedDepositableAdapters(erc20AdapterAddress));
|
|
148
|
+
// console.log(await rwaVaultContract.depositableAdapters(1));
|
|
149
|
+
// await rwaVaultContract.setIndexTokenMintingFee(0);
|
|
150
|
+
await rpc.wallet.assets.approveAsset(chainId, "crvusd", erc20AdapterAddress, "200", signer);
|
|
151
|
+
const data = new ethers_1.ethers.AbiCoder().encode(["uint256"], [ethers_1.ethers.parseEther("200")]);
|
|
152
|
+
await rpc.pools.rwaVault.depositToRWAVault(chainId, "crvusdadapter", data, signer.address, signer);
|
|
153
|
+
console.log(await rwaVaultContract.pricePerShare());
|
|
154
|
+
console.log(await vaultTokenContract.balanceOf(signer.address));
|
|
155
|
+
console.log(await crvusdContract.balanceOf(signer.address));
|
|
156
|
+
console.log(await crvusdContract.balanceOf(erc20AdapterAddress));
|
|
157
|
+
console.log(await crvusdContract.allowance(signer.address, await rwaVaultContract.getAddress()));
|
|
120
158
|
};
|
|
121
159
|
const updateNFTPrice = async (id, price) => {
|
|
122
160
|
const provider = await getProvider();
|
|
@@ -232,7 +232,7 @@ declare class RPCLibrary {
|
|
|
232
232
|
setChainsConfig: typeof setChainConfig;
|
|
233
233
|
constructor(privateKey?: string);
|
|
234
234
|
getWallet(privateKey: string, provider: Provider): Promise<ethers.JsonRpcSigner | ethers.Wallet>;
|
|
235
|
-
getProvider(chainId: ChainId, providerRpc?: string): Promise<ethers.
|
|
235
|
+
getProvider(chainId: ChainId, providerRpc?: string): Promise<ethers.BrowserProvider | ethers.JsonRpcProvider>;
|
|
236
236
|
getSigner(chainId: ChainId, address: string): Promise<ethers.JsonRpcSigner>;
|
|
237
237
|
connectWallet(): Promise<void>;
|
|
238
238
|
checkConnection(): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BytesLike, ethers } from "ethers";
|
|
1
|
+
import { BytesLike, ethers, Provider, Signer } from "ethers";
|
|
2
2
|
import { ChainId } from "../../configs/chains";
|
|
3
3
|
import { Adapter } from "../../configs/chains/chain";
|
|
4
4
|
import { RWAVault } from "../../typechain-types";
|
|
@@ -7,4 +7,4 @@ export declare function decodeERC721(data: BytesLike): ethers.Result;
|
|
|
7
7
|
export declare function encodeERC20(amount: string): string;
|
|
8
8
|
export declare function decodeERC20(data: BytesLike): bigint;
|
|
9
9
|
export declare function getRWAVaultAdapterByAddress(chainId: ChainId, address: string): Adapter;
|
|
10
|
-
export declare function getRWAVaultContract(chainId: ChainId): Promise<RWAVault>;
|
|
10
|
+
export declare function getRWAVaultContract(chainId: ChainId, provider_signer?: Provider | Signer): Promise<RWAVault>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
2
|
import { ChainId } from "../../configs/chains/index";
|
|
3
3
|
interface RWAVaultInfo {
|
|
4
4
|
totalAssets: string;
|
|
@@ -16,5 +16,5 @@ interface RWAVaultInfo {
|
|
|
16
16
|
llamaPerkMultiplier: string;
|
|
17
17
|
llamaPerkClassName: string;
|
|
18
18
|
}
|
|
19
|
-
declare function getRWAVaultInfo(chainId: ChainId,
|
|
19
|
+
declare function getRWAVaultInfo(chainId: ChainId, provider: Provider): Promise<RWAVaultInfo>;
|
|
20
20
|
export default getRWAVaultInfo;
|