@raac/rpc 1.1.0-beta.60 → 1.1.0-beta.61
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,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.encryptSecrets = encryptSecrets;
|
|
7
|
+
const configs_1 = require("../configs");
|
|
8
|
+
const chainlink_networks_config_1 = __importDefault(require("./chainlink-networks-config"));
|
|
9
|
+
const functions_toolkit_1 = require("@chainlink/functions-toolkit");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
async function encryptSecrets(chainId, secrets, outputFile, signerV5) {
|
|
12
|
+
const chain = (0, configs_1.getChainConfig)(chainId);
|
|
13
|
+
const network = chainlink_networks_config_1.default[chainId];
|
|
14
|
+
if (!chain) {
|
|
15
|
+
throw new Error(`Chain configuration not found for chainId: ${chainId}`);
|
|
16
|
+
}
|
|
17
|
+
const functionsRouterAddress = network.functionsRouter;
|
|
18
|
+
const donId = network.donId;
|
|
19
|
+
const secretsManager = new functions_toolkit_1.SecretsManager({
|
|
20
|
+
// ethers v5 signer again
|
|
21
|
+
signer: signerV5,
|
|
22
|
+
functionsRouterAddress,
|
|
23
|
+
donId,
|
|
24
|
+
});
|
|
25
|
+
await secretsManager.initialize();
|
|
26
|
+
const encryptedSecrets = await secretsManager.encryptSecrets(secrets);
|
|
27
|
+
fs_1.default.writeFileSync(outputFile, JSON.stringify(encryptedSecrets, null, 2), { encoding: 'utf8' });
|
|
28
|
+
return encryptedSecrets;
|
|
29
|
+
}
|
|
@@ -12,13 +12,14 @@ const ethers5_1 = require("ethers5");
|
|
|
12
12
|
const config_1 = __importDefault(require("./config"));
|
|
13
13
|
const chainlink_networks_config_1 = __importDefault(require("../chainlink-networks-config"));
|
|
14
14
|
const artifacts_1 = require("../../utils/artifacts");
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
16
|
const subscriptionIds = {
|
|
16
17
|
8453: 4392,
|
|
17
18
|
17000: 4392,
|
|
18
19
|
11155111: 4392,
|
|
19
20
|
18453: 4392,
|
|
20
21
|
};
|
|
21
|
-
async function generateSecretReference(chainId, signerV5) {
|
|
22
|
+
async function generateSecretReference(chainId, secrets, signerV5) {
|
|
22
23
|
const chain = (0, configs_1.getChainConfig)(chainId);
|
|
23
24
|
const network = chainlink_networks_config_1.default[chainId];
|
|
24
25
|
if (!chain) {
|
|
@@ -34,19 +35,21 @@ async function generateSecretReference(chainId, signerV5) {
|
|
|
34
35
|
donId,
|
|
35
36
|
});
|
|
36
37
|
await secretsManager.initialize();
|
|
37
|
-
const encryptedSecrets = await secretsManager.encryptSecrets(
|
|
38
|
+
const encryptedSecrets = await secretsManager.encryptSecrets(secrets);
|
|
39
|
+
fs_1.default.writeFileSync("encryptedFunctionsBeaconSecrets.json", JSON.stringify(encryptedSecrets, null, 2), { encoding: 'utf8' });
|
|
38
40
|
// DONHoster secrets
|
|
39
|
-
const { version } = await secretsManager.uploadEncryptedSecretsToDON({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
const encryptedSecretsReference =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
// const { version } = await secretsManager.uploadEncryptedSecretsToDON({
|
|
42
|
+
// encryptedSecretsHexstring: encryptedSecrets.encryptedSecrets,
|
|
43
|
+
// gatewayUrls: network.gatewayUrls,
|
|
44
|
+
// slotId,
|
|
45
|
+
// minutesUntilExpiration: 3600,
|
|
46
|
+
// });
|
|
47
|
+
// const encryptedSecretsReference =
|
|
48
|
+
// await secretsManager.buildDONHostedEncryptedSecretsReference({
|
|
49
|
+
// slotId,
|
|
50
|
+
// version,
|
|
51
|
+
// });
|
|
52
|
+
return encryptedSecrets;
|
|
50
53
|
}
|
|
51
54
|
async function request(chainId, houseId, signerV5) {
|
|
52
55
|
const chain = (0, configs_1.getChainConfig)(chainId);
|
package/dist/scripts/index.js
CHANGED
|
@@ -38,6 +38,7 @@ async function setup() {
|
|
|
38
38
|
const rpc = new RPCLibrary_1.default();
|
|
39
39
|
const provider = await getProvider();
|
|
40
40
|
const signer = await createWallet(TEST_MNEMONIC, provider);
|
|
41
|
+
console.log(await signer.getAddress());
|
|
41
42
|
// const rpc = new RPCLibrary();
|
|
42
43
|
rpc.address = signer.address;
|
|
43
44
|
rpc.provider = provider;
|
|
@@ -63,11 +64,29 @@ async function setup() {
|
|
|
63
64
|
const StabilityPoolContract = new ethers_1.ethers.Contract(StabilityPoolAddress, StabilityPoolABI, signer);
|
|
64
65
|
const providerV5 = new ethers5_1.ethers.providers.JsonRpcProvider(config.rpcs[0]);
|
|
65
66
|
const signerV5 = new ethers5_1.ethers.Wallet(TEST_PRIVATE_KEY, providerV5);
|
|
67
|
+
console.log(await signerV5.getAddress());
|
|
66
68
|
const TreasuryAddress = (0, contracts_1.getContractAddress)(chainId, "treasury");
|
|
67
69
|
const TreasuryABI = (0, artifacts_1.getABI)("treasury");
|
|
68
70
|
const TreasuryContract = new ethers_1.ethers.Contract(TreasuryAddress, TreasuryABI, signer);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
+
// const secretsReference = await encryptSecrets(chainId, {
|
|
72
|
+
// apiKey: process.env.FRED_API_KEY as string,
|
|
73
|
+
// }, "encryptedFunctionsPrimeRateSecrets.json", signerV5);
|
|
74
|
+
// console.log(secretsReference);
|
|
75
|
+
// return;
|
|
76
|
+
const encryptedURL = await (0, encryptSecretURLs_1.encryptSecretURLs)(chainId, ["https://emerald-many-grasshopper-318.mypinata.cloud/ipfs/bafkreidwvgtxxeijgdfpujh7dh6wwliomxsmn2qg4ey37ql52oqqoly55m"], signerV5);
|
|
77
|
+
console.log(encryptedURL);
|
|
78
|
+
return;
|
|
79
|
+
// const secretReference = await generateSecretReference(chainId, {
|
|
80
|
+
// ATTESTATIONS_AUDITOR_BISCUIT: process.env.ATTESTATIONS_AUDITOR_BISCUIT as string,
|
|
81
|
+
// ATTESTATION_BATCHES_BISCUIT: process.env.ATTESTATION_BATCHES_BISCUIT as string,
|
|
82
|
+
// ATTESTATIONS_BISCUIT: process.env.ATTESTATIONS_BISCUIT as string,
|
|
83
|
+
// BLOCKCHAINS_BISCUIT: process.env.BLOCKCHAINS_BISCUIT as string,
|
|
84
|
+
// SXT_API_KEY: process.env.SXT_API_KEY as string,
|
|
85
|
+
// }, signerV5)
|
|
86
|
+
// console.log(secretReference);
|
|
87
|
+
// const encryptURL = await encryptSecretURLs(chainId, ["https://emerald-many-grasshopper-318.mypinata.cloud/ipfs/bafkreifvuyg7rsfx2wbyeulc267mvg5nwak2ggaxnr723zbekuzycjiysa"], signerV5);
|
|
88
|
+
// console.log(encryptURL);
|
|
89
|
+
// return;
|
|
71
90
|
// await (await housePriceContract.setOracle(signer.address)).wait();
|
|
72
91
|
// console.log(await rpc.pools.lendingPool.getLendingPoolInfo(chainId, signer.address, provider))
|
|
73
92
|
// console.log(await LendingPoolContract.rateData())
|
|
@@ -77,41 +96,7 @@ async function setup() {
|
|
|
77
96
|
// console.log(tx);
|
|
78
97
|
// let tx = await StabilityPoolContract.setLiquidationVaultTokenSplit(2_50, 2_50, 90_00, 5_00)
|
|
79
98
|
// await tx.wait();
|
|
80
|
-
return;
|
|
81
|
-
console.log(await StabilityPoolContract.liquidationSplit());
|
|
82
|
-
console.log(await StabilityPoolContract.liquidationSwap());
|
|
83
|
-
console.log(await StabilityPoolContract.liquidityGauge());
|
|
84
|
-
console.log(await StabilityPoolContract.treasury());
|
|
85
|
-
const tx = await StabilityPoolContract.liquidateBorrower("0x8DCc5f781933A6232d7aA6003cb5b07138B7A8AA", "0x0C45430F37ce079740b55B323c090b3B498DBdf0", "0xC3f1d3048fE5De050ca2965e47981f5C0039A2d8", new ethers_1.ethers.AbiCoder().encode(["uint256"], [150]));
|
|
86
|
-
await tx.wait();
|
|
87
|
-
console.log(tx);
|
|
88
|
-
const position = await LendingPoolContract.getPositionView("0x8DCc5f781933A6232d7aA6003cb5b07138B7A8AA", "0xC3f1d3048fE5De050ca2965e47981f5C0039A2d8", new ethers_1.ethers.AbiCoder().encode(["uint256"], [150]));
|
|
89
|
-
console.log(position);
|
|
90
|
-
return;
|
|
91
|
-
function randomBetween(min, max) {
|
|
92
|
-
return Math.random() * (max - min) + min;
|
|
93
|
-
}
|
|
94
|
-
// Pick 5 NFTs for the deeper cut
|
|
95
|
-
const bigCutIds = new Set([10, 50, 100, 150, 200]);
|
|
96
|
-
for (let nft = 1; nft <= 201; nft++) {
|
|
97
|
-
const price = await rpc.nfts.getHousePrice(chainId, Number(nft), provider);
|
|
98
|
-
// Decide discount %: 20–30% normally, 40–50% for special ones
|
|
99
|
-
const discount = bigCutIds.has(nft)
|
|
100
|
-
? randomBetween(0.40, 0.50)
|
|
101
|
-
: randomBetween(0.20, 0.30);
|
|
102
|
-
const newPrice = parseFloat(price) * (1 - discount);
|
|
103
|
-
// same format as before
|
|
104
|
-
console.log(nft, newPrice);
|
|
105
|
-
}
|
|
106
|
-
return;
|
|
107
99
|
// Add funds in the Mock Liquidity Pool
|
|
108
|
-
const CURVE_POOL_ADDRESSES = {
|
|
109
|
-
11155111: '0x645A38Bbe56Dc014fb28536bEA9796b2b2D92c0c', // Sepolia
|
|
110
|
-
8453: '0x5eb3Bc0a489C5A8288765d2336659EbCA68FCd00', // Base
|
|
111
|
-
};
|
|
112
|
-
const MockLiquidityPoolAddress = CURVE_POOL_ADDRESSES[chainId];
|
|
113
|
-
const MockLiquidityPoolABI = ["function add_liquidity(uint256[2] memory amounts, uint256) external returns (uint256)", "function getTotalLiquidity(address _pairedToken) external view returns (uint256 raacLiquidity, uint256 pairedLiquidity)"];
|
|
114
|
-
const MockLiquidityPoolContract = new ethers_1.ethers.Contract(MockLiquidityPoolAddress, MockLiquidityPoolABI, signer);
|
|
115
100
|
// mint 10 million in crvusd
|
|
116
101
|
// console.log("Minting 10 million in crvusd");
|
|
117
102
|
// await rpc.wallet.assets.mintAsset(chainId, "crvusd", 10000000n, signer.address, signer)
|
|
@@ -131,29 +116,34 @@ async function setup() {
|
|
|
131
116
|
// const liquidity = await MockLiquidityPoolContract.getTotalLiquidity(await rpc.contracts.getContractAddress(chainId, "rwaindextoken"))
|
|
132
117
|
// console.log("Liquidity in the Mock Liquidity Pool", liquidity);
|
|
133
118
|
// mint the current user 5 million irAAC
|
|
134
|
-
console.log("Minting 5 million irAAC");
|
|
119
|
+
// console.log("Minting 5 million irAAC");
|
|
135
120
|
// await rpc.wallet.assets.approveAsset(chainId, "crvusd", await rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter").address, "5000000", signer);
|
|
136
121
|
// const data = new ethers.AbiCoder().encode(["uint256"], [ ethers.parseEther("5000000") ])
|
|
137
122
|
// await rpc.pools.rwaVault.depositToRWAVault(chainId, "crvusdadapter", data, signer.address, signer)
|
|
138
123
|
/// END OF ADD FUNDS IN THE MOCK LIQUIDITY POOL
|
|
139
|
-
// // send myself some CRVUSD
|
|
140
|
-
await rpc.wallet.assets.mintAsset(
|
|
124
|
+
// // // send myself some CRVUSD
|
|
125
|
+
// await rpc.wallet.assets.mintAsset(
|
|
126
|
+
// chainId,
|
|
127
|
+
// "crvusd",
|
|
128
|
+
// 10000000n,
|
|
129
|
+
// signer.address,
|
|
130
|
+
// signer
|
|
131
|
+
// );
|
|
141
132
|
// set the base uri to instruxi data gateway
|
|
142
|
-
await rpc.nfts.setBaseUri(chainId, "http://
|
|
133
|
+
await rpc.nfts.setBaseUri(chainId, "http://3.86.253.54:3000/v1/properties/", signer);
|
|
134
|
+
return;
|
|
143
135
|
const RWAVaultAddress = (0, contracts_1.getContractAddress)(chainId, "rwavault");
|
|
144
136
|
const RWAVaultABI = (0, artifacts_1.getABI)("rwavault");
|
|
145
137
|
const RWAVaultContract = new ethers_1.ethers.Contract(RWAVaultAddress, RWAVaultABI, signer);
|
|
146
|
-
// @ts-ignore
|
|
147
|
-
if (chainId === 11155111) {
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
// @ts-ignore
|
|
151
|
-
if (chainId !== 8453) {
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
console.log(
|
|
155
|
-
console.log(await rpc.wallet.assets.getBalance(chainId, "rtoken", signer.address, provider));
|
|
156
|
-
console.log(await rpc.nfts.getTokensByOwner(chainId, signer.address, provider));
|
|
138
|
+
// // @ts-ignore
|
|
139
|
+
// if (chainId === 11155111) {
|
|
140
|
+
// await RWAVaultContract.setVRFConsumer("0x244dC85807D947B2c590DEb1A340B818d5CD59B9")
|
|
141
|
+
// }
|
|
142
|
+
// // @ts-ignore
|
|
143
|
+
// if (chainId !== 8453) {
|
|
144
|
+
// return;
|
|
145
|
+
// }
|
|
146
|
+
console.log("hello");
|
|
157
147
|
// // // set the oracle address of the RAACHousePrice. TEmporarily simulating that I AM THE ORACLE
|
|
158
148
|
await rpc.contracts.housePrices.setOracle(chainId, signer.address, signer);
|
|
159
149
|
const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Signer } from "ethers5";
|
|
2
|
-
export declare function generateSecretReference(chainId: number, signerV5: Signer): Promise<
|
|
2
|
+
export declare function generateSecretReference(chainId: number, secrets: Record<string, string>, signerV5: Signer): Promise<{
|
|
3
|
+
encryptedSecrets: string;
|
|
4
|
+
}>;
|
|
3
5
|
export declare function request(chainId: number, houseId: string, signerV5: Signer): Promise<void>;
|