@raac/rpc 1.1.0-beta.83 → 1.1.0-beta.85

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.
Files changed (33) hide show
  1. package/dist/artifacts/core/collectors/FeeCollector.sol/FeeCollector.json +2 -2
  2. package/dist/artifacts/core/minters/RAACMinter/RAACMinter.sol/RAACMinter.json +2 -2
  3. package/dist/artifacts/core/oracles/RAACPrimeRateOracle.sol/RAACPrimeRateOracle.json +2 -2
  4. package/dist/artifacts/core/pools/LendingPool/LendingPool.sol/LendingPool.json +20 -10
  5. package/dist/artifacts/core/pools/StabilityPool/StabilityPool.sol/StabilityPool.json +2 -2
  6. package/dist/artifacts/core/tokens/DEToken.sol/DEToken.json +63 -7
  7. package/dist/artifacts/core/tokens/RToken.sol/RToken.json +58 -2
  8. package/dist/artifacts/core/vaults/RWAVault.sol/RWAVault.json +2 -20
  9. package/dist/configs/chains/17000.json +10 -0
  10. package/dist/configs/chains/18453.json +10 -0
  11. package/dist/configs/chains/8453.json +5 -0
  12. package/dist/oracles/encryptSecretURLs.js +6 -17
  13. package/dist/oracles/encryptSecrets.js +5 -19
  14. package/dist/oracles/houses/config.js +6 -5
  15. package/dist/oracles/houses/request.js +31 -60
  16. package/dist/oracles/houses/simulate.js +4 -3
  17. package/dist/oracles/prime-rate/config.js +6 -5
  18. package/dist/oracles/prime-rate/request.js +33 -42
  19. package/dist/oracles/prime-rate/simulate.js +4 -3
  20. package/dist/pools/rwaVault/getRWAVaultInfo.js +3 -1
  21. package/dist/scripts/index.js +3 -10
  22. package/dist/scripts/liquidation.js +13 -29
  23. package/dist/types/oracles/encryptSecretURLs.d.ts +4 -4
  24. package/dist/types/oracles/encryptSecrets.d.ts +2 -4
  25. package/dist/types/oracles/houses/config.d.ts +4 -5
  26. package/dist/types/oracles/houses/request.d.ts +3 -5
  27. package/dist/types/oracles/prime-rate/config.d.ts +4 -5
  28. package/dist/types/oracles/prime-rate/request.d.ts +2 -2
  29. package/dist/types/pools/rwaVault/getRWAVaultInfo.d.ts +1 -0
  30. package/dist/types/utils/artifacts.d.ts +0 -113
  31. package/dist/utils/artifacts.js +0 -2
  32. package/package.json +8 -9
  33. package/dist/artifacts/core/collectors/NFTRoyaltyFeeCollector.sol/NFTRoyaltyFeeCollector.json +0 -246
@@ -1,23 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.encryptSecretURLs = encryptSecretURLs;
7
- const functions_toolkit_1 = require("@chainlink/functions-toolkit");
8
- const chainlink_networks_config_1 = __importDefault(require("./chainlink-networks-config"));
9
- async function encryptSecretURLs(chainId, urls, signerV5) {
10
- const network = chainlink_networks_config_1.default[chainId];
11
- const functionsRouterAddress = network.functionsRouter;
12
- const donId = network.donId;
13
- const secretsManager = new functions_toolkit_1.SecretsManager({
14
- signer: signerV5,
15
- functionsRouterAddress,
16
- donId,
17
- });
18
- await secretsManager.initialize();
19
- const encryptedSecrets = await secretsManager.encryptSecretsUrls(urls);
20
- const isVerified = await secretsManager.verifyOffchainSecrets(urls);
4
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
5
+ async function encryptSecretURLs(chainId, urls, signer) {
6
+ const { chain, network } = chainlinkjs_1.utils.getChainAndNetwork(chainId);
7
+ const secretsConnector = new chainlinkjs_1.connectors.ChainlinkSecretsConnector(signer, { chain, network });
8
+ const encryptedSecrets = await secretsConnector.encryptSecretsUrls(urls);
9
+ const isVerified = await secretsConnector.verifyOffchainSecrets(urls);
21
10
  if (!isVerified) {
22
11
  throw new Error("Offchain secrets verification failed");
23
12
  }
@@ -4,26 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
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");
7
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
10
8
  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);
9
+ async function encryptSecrets(chainId, secrets, outputFile, signer) {
10
+ const { chain, network } = chainlinkjs_1.utils.getChainAndNetwork(chainId);
11
+ const secretsConnector = new chainlinkjs_1.connectors.ChainlinkSecretsConnector(signer, chain, network);
12
+ const encryptedSecrets = await secretsConnector.encryptSecrets(secrets);
27
13
  fs_1.default.writeFileSync(outputFile, JSON.stringify(encryptedSecrets, null, 2), { encoding: 'utf8' });
28
14
  return encryptedSecrets;
29
15
  }
@@ -4,16 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = __importDefault(require("fs"));
7
- const functions_toolkit_1 = require("@chainlink/functions-toolkit");
7
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
8
+ const { Location, ReturnType, CodeLanguage } = chainlinkjs_1.enums;
8
9
  const requestConfig = {
9
10
  source: fs_1.default.readFileSync("./oracles/houses/api.js").toString(),
10
- codeLocation: functions_toolkit_1.Location.Inline,
11
+ codeLocation: Location.Inline,
11
12
  // Optional
12
13
  secrets: { apiKey: process.env.RAAC_HOUSING_API_KEY ?? "" },
13
14
  // Optional
14
- secretsLocation: functions_toolkit_1.Location.DONHosted,
15
+ secretsLocation: Location.DONHosted,
15
16
  args: [],
16
- codeLanguage: functions_toolkit_1.CodeLanguage.JavaScript,
17
- expectedReturnType: functions_toolkit_1.ReturnType.uint256,
17
+ codeLanguage: CodeLanguage.JavaScript,
18
+ expectedReturnType: ReturnType.uint256,
18
19
  };
19
20
  exports.default = requestConfig;
@@ -5,36 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateSecretReference = generateSecretReference;
7
7
  exports.request = request;
8
- const functions_toolkit_1 = require("@chainlink/functions-toolkit");
9
- const configs_1 = require("../../configs");
10
- const getContractAddress_1 = __importDefault(require("../../contracts/getContractAddress"));
11
- const ethers5_1 = require("ethers5");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const ethers_1 = require("ethers");
10
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
11
+ const { decodeResult, simulateScript, decomposeFromChainId } = chainlinkjs_1.utils;
12
+ const { ChainlinkFunctionConnector, ChainlinkSecretsConnector } = chainlinkjs_1.connectors;
13
+ const FulfillmentCode = chainlinkjs_1.enums.FulfillmentCode;
14
+ const ResponseListener = chainlinkjs_1.listeners.ResponseListener;
12
15
  const config_1 = __importDefault(require("./config"));
13
- const chainlink_networks_config_1 = __importDefault(require("../chainlink-networks-config"));
16
+ const getContractAddress_1 = __importDefault(require("../../contracts/getContractAddress"));
14
17
  const artifacts_1 = require("../../utils/artifacts");
15
- const fs_1 = __importDefault(require("fs"));
16
18
  const subscriptionIds = {
17
19
  8453: 4392,
18
20
  17000: 4392,
19
21
  11155111: 4392,
20
22
  18453: 4392,
21
23
  };
22
- async function generateSecretReference(chainId, secrets, signerV5) {
23
- const chain = (0, configs_1.getChainConfig)(chainId);
24
- const network = chainlink_networks_config_1.default[chainId];
25
- if (!chain) {
26
- throw new Error(`Chain configuration not found for chainId: ${chainId}`);
27
- }
24
+ async function generateSecretReference(chainId, secrets, signer) {
28
25
  const slotId = 0;
29
- const functionsRouterAddress = network.functionsRouter;
30
- const donId = network.donId;
31
- const secretsManager = new functions_toolkit_1.SecretsManager({
32
- // ethers v5 signer again
33
- signer: signerV5,
34
- functionsRouterAddress,
35
- donId,
36
- });
37
- await secretsManager.initialize();
26
+ const { chain, network } = decomposeFromChainId(chainId);
27
+ const secretsManager = new ChainlinkSecretsConnector(signer, { chain, network });
38
28
  const encryptedSecrets = await secretsManager.encryptSecrets(secrets);
39
29
  fs_1.default.writeFileSync("encryptedFunctionsBeaconSecrets.json", JSON.stringify(encryptedSecrets, null, 2), { encoding: 'utf8' });
40
30
  // DONHoster secrets
@@ -51,20 +41,16 @@ async function generateSecretReference(chainId, secrets, signerV5) {
51
41
  // });
52
42
  return encryptedSecrets;
53
43
  }
54
- async function request(chainId, houseId, signerV5) {
55
- const chain = (0, configs_1.getChainConfig)(chainId);
56
- const network = chainlink_networks_config_1.default[chainId];
57
- if (!chain) {
58
- throw new Error(`Chain configuration not found for chainId: ${chainId}`);
59
- }
44
+ async function request(chainId, houseId, signer) {
45
+ const { chain, network } = decomposeFromChainId(chainId);
60
46
  // Simulate the request first
61
47
  {
62
- const { responseBytesHexstring, errorString } = await (0, functions_toolkit_1.simulateScript)({
48
+ const { responseBytesHexstring, errorString } = await simulateScript({
63
49
  ...config_1.default,
64
50
  args: [houseId],
65
51
  });
66
52
  if (responseBytesHexstring) {
67
- console.log(`\nResponse returned by script during local simulation: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
53
+ console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
68
54
  }
69
55
  if (errorString) {
70
56
  console.log(`\nError returned by simulated script:\n${errorString}\n`);
@@ -76,42 +62,27 @@ async function request(chainId, houseId, signerV5) {
76
62
  const subscriptionId = subscriptionIds[chainId];
77
63
  const slotId = 0;
78
64
  const callbackGasLimit = 300_000;
79
- const consumerContract = new ethers5_1.ethers.Contract(contractAddress, contractAbi, signerV5);
80
- const linkTokenAddress = network.linkToken;
65
+ const consumerContract = new ethers_1.ethers.Contract(contractAddress, contractAbi, signer);
81
66
  const functionsRouterAddress = network.functionsRouter;
82
- const subscriptionManager = new functions_toolkit_1.SubscriptionManager({
83
- // Use the v5 signer here (toolkit expects ethers v5 types)
84
- signer: signerV5,
85
- linkTokenAddress,
86
- functionsRouterAddress,
87
- });
88
- await subscriptionManager.initialize();
89
- const donId = network.donId;
90
- const secretsManager = new functions_toolkit_1.SecretsManager({
91
- // ethers v5 signer again
92
- signer: signerV5,
93
- functionsRouterAddress,
94
- donId,
95
- });
96
- await secretsManager.initialize();
97
- const subInfo = await subscriptionManager.getSubscriptionInfo(subscriptionId);
67
+ const subscriptionManager = new ChainlinkFunctionConnector(signer, { chain, network });
68
+ const secretsManager = new ChainlinkSecretsConnector(signer, { chain, network });
69
+ const subInfo = await subscriptionManager.getSubscription(subscriptionId);
98
70
  if (!subInfo.consumers
99
71
  .map((c) => c.toLowerCase())
100
72
  .includes(contractAddress.toLowerCase())) {
101
73
  throw Error(`Consumer contract ${contractAddress} has not been added to subscription ${subscriptionId}`);
102
74
  }
103
- // Use the v5 provider for gas data (to avoid type mismatches)
104
- const { gasPrice } = await signerV5.provider.getFeeData();
75
+ const { gasPrice } = await signer.provider.getFeeData();
105
76
  // @ts-ignore
106
- const gasPriceWei = BigInt(Math.ceil(ethers5_1.ethers.utils.formatUnits(gasPrice, "wei").toString()));
77
+ const gasPriceWei = BigInt(Math.ceil(ethers_1.ethers.formatUnits(gasPrice, "wei").toString()));
107
78
  const estimatedCostJuels = await subscriptionManager.estimateFunctionsRequestCost({
108
- donId,
79
+ donId: subscriptionManager.donId,
109
80
  subscriptionId,
110
81
  callbackGasLimit,
111
82
  gasPriceWei,
112
83
  });
113
- const estimatedCostLink = ethers5_1.ethers.utils.formatUnits(estimatedCostJuels.toString(), 18);
114
- const subBalanceLink = ethers5_1.ethers.utils.formatUnits(subInfo.balance.toString(), 18);
84
+ const estimatedCostLink = ethers_1.ethers.formatUnits(estimatedCostJuels.toString(), 18);
85
+ const subBalanceLink = ethers_1.ethers.parseUnits(subInfo.balance, 18);
115
86
  if (subInfo.balance <= estimatedCostJuels) {
116
87
  throw Error(`Subscription ${subscriptionId} does not have sufficient funds. The estimated cost is ${estimatedCostLink} LINK, but the subscription only has ${subBalanceLink} LINK.`);
117
88
  }
@@ -127,8 +98,8 @@ async function request(chainId, houseId, signerV5) {
127
98
  slotId,
128
99
  version,
129
100
  });
130
- const responseListener = new functions_toolkit_1.ResponseListener({
131
- provider: signerV5.provider,
101
+ const responseListener = new ResponseListener({
102
+ provider: signer.provider,
132
103
  functionsRouterAddress,
133
104
  });
134
105
  console.log(`Waiting for transaction for RAACHousePriceOracle contract ${contractAddress} on network ${network.name} to be confirmed...`);
@@ -146,9 +117,9 @@ async function request(chainId, houseId, signerV5) {
146
117
  // Get response data
147
118
  const { requestId, totalCostInJuels, responseBytesHexstring, errorString, fulfillmentCode, } = await responseListener.listenForResponseFromTransaction(requestTx.hash, undefined, NUM_CONFIRMATIONS, undefined);
148
119
  switch (fulfillmentCode) {
149
- case functions_toolkit_1.FulfillmentCode.FULFILLED:
120
+ case FulfillmentCode.FULFILLED:
150
121
  if (responseBytesHexstring !== "0x") {
151
- console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
122
+ console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
152
123
  }
153
124
  else if (errorString.length > 0) {
154
125
  console.error(`Request ${requestId} fulfilled with error: ${errorString}\n`);
@@ -156,13 +127,13 @@ async function request(chainId, houseId, signerV5) {
156
127
  else {
157
128
  console.warn(`Request ${requestId} fulfilled with empty response data.\n`);
158
129
  }
159
- const linkCost = ethers5_1.ethers.utils.formatUnits(totalCostInJuels.toString(), 18);
130
+ const linkCost = ethers_1.ethers.formatUnits(totalCostInJuels.toString(), 18);
160
131
  console.log(`Total request cost: ${linkCost + " LINK"}`);
161
132
  break;
162
- case functions_toolkit_1.FulfillmentCode.USER_CALLBACK_ERROR:
133
+ case FulfillmentCode.USER_CALLBACK_ERROR:
163
134
  console.error("Error encountered when calling consumer contract callback.\nEnsure the fulfillRequest function in RAACHousePriceOracle is correct and the --callbackgaslimit is sufficient.");
164
135
  break;
165
- case functions_toolkit_1.FulfillmentCode.COST_EXCEEDS_COMMITMENT:
136
+ case FulfillmentCode.COST_EXCEEDS_COMMITMENT:
166
137
  console.error(`Request ${requestId} failed due to a gas price spike when attempting to respond.`);
167
138
  break;
168
139
  default:
@@ -4,15 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.simulate = simulate;
7
- const functions_toolkit_1 = require("@chainlink/functions-toolkit");
7
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
8
+ const { simulateScript, decodeResult } = chainlinkjs_1.utils;
8
9
  const config_1 = __importDefault(require("./config"));
9
10
  async function simulate(houseId) {
10
- const { responseBytesHexstring, errorString } = await (0, functions_toolkit_1.simulateScript)({
11
+ const { responseBytesHexstring, errorString } = await simulateScript({
11
12
  ...config_1.default,
12
13
  args: [houseId],
13
14
  });
14
15
  if (responseBytesHexstring) {
15
- console.log(`\nResponse returned by script during local simulation: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
16
+ console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
16
17
  }
17
18
  if (errorString) {
18
19
  console.log(`\nError returned by simulated script:\n${errorString}\n`);
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const functions_toolkit_1 = require("@chainlink/functions-toolkit");
3
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
4
+ const { Location, ReturnType, CodeLanguage } = chainlinkjs_1.enums;
4
5
  const requestConfig = {
5
6
  name: "prime-rate",
6
7
  sourceURL: "https://emerald-many-grasshopper-318.mypinata.cloud/ipfs/bafkreid3kubchc3f2sspzq25pnmnw3mppkhv46xvzg72xx7zqs2plvjbqu",
7
- codeLocation: functions_toolkit_1.Location["Inline"],
8
+ codeLocation: Location["Inline"],
8
9
  // Optional
9
10
  secrets: { apiKey: process.env.FRED_API_KEY ?? "" },
10
11
  // Optional
11
- secretsLocation: functions_toolkit_1.Location["DONHosted"],
12
+ secretsLocation: Location["DONHosted"],
12
13
  args: [],
13
- codeLanguage: functions_toolkit_1.CodeLanguage.JavaScript,
14
- expectedReturnType: functions_toolkit_1.ReturnType.uint256,
14
+ codeLanguage: CodeLanguage.JavaScript,
15
+ expectedReturnType: ReturnType.uint256,
15
16
  };
16
17
  exports.default = requestConfig;
@@ -4,10 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.request = request;
7
- const functions_toolkit_1 = require("@chainlink/functions-toolkit");
7
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
8
+ const { decodeResult, simulateScript, decomposeFromChainId } = chainlinkjs_1.utils;
9
+ const { ChainlinkFunctionConnector, ChainlinkSecretsConnector } = chainlinkjs_1.connectors;
10
+ const FulfillmentCode = chainlinkjs_1.enums.FulfillmentCode;
11
+ const ResponseListener = chainlinkjs_1.listeners.ResponseListener;
12
+ const ethers_1 = require("ethers");
8
13
  const configs_1 = require("../../configs");
9
14
  const getContractAddress_1 = __importDefault(require("../../contracts/getContractAddress"));
10
- const ethers5_1 = require("ethers5");
11
15
  const config_1 = __importDefault(require("./config"));
12
16
  const chainlink_networks_config_1 = __importDefault(require("../chainlink-networks-config"));
13
17
  const artifacts_1 = require("../../utils/artifacts");
@@ -17,10 +21,10 @@ const subscriptionIds = {
17
21
  11155111: 4392,
18
22
  18453: 4392,
19
23
  };
20
- async function request(chainId, signerV5) {
21
- const chain = (0, configs_1.getChainConfig)(chainId);
22
- const network = chainlink_networks_config_1.default[chainId];
23
- if (!chain) {
24
+ async function request(chainId, signer) {
25
+ const chainConfig = (0, configs_1.getChainConfig)(chainId);
26
+ const networkConfig = chainlink_networks_config_1.default[chainId];
27
+ if (!chainConfig) {
24
28
  throw new Error(`Chain configuration not found for chainId: ${chainId}`);
25
29
  }
26
30
  const sourceFetch = await fetch(config_1.default.sourceURL);
@@ -28,12 +32,12 @@ async function request(chainId, signerV5) {
28
32
  console.log("Reading source from URL: ", config_1.default.sourceURL);
29
33
  // Simulate the request first
30
34
  {
31
- const { responseBytesHexstring, errorString } = await (0, functions_toolkit_1.simulateScript)({
35
+ const { responseBytesHexstring, errorString } = await simulateScript({
32
36
  ...config_1.default,
33
37
  source,
34
38
  });
35
39
  if (responseBytesHexstring) {
36
- console.log(`\nResponse returned by script during local simulation: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
40
+ console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
37
41
  }
38
42
  if (errorString) {
39
43
  console.log(`\nError returned by simulated script:\n${errorString}\n`);
@@ -41,7 +45,7 @@ async function request(chainId, signerV5) {
41
45
  console.log("Local simulation of source code completed...");
42
46
  }
43
47
  // Get the RPC endpoint from the chain config and derive a v5 provider
44
- const rpcUrl = chain.rpcs?.[0] ?? chain.rpc ?? undefined;
48
+ const rpcUrl = chainConfig.rpcs?.[0] ?? chainConfig.rpc ?? undefined;
45
49
  if (!rpcUrl)
46
50
  throw new Error("No RPC URL found in chain configuration");
47
51
  const contractAddress = (0, getContractAddress_1.default)(chainId, "raacprimerateoracle");
@@ -49,42 +53,29 @@ async function request(chainId, signerV5) {
49
53
  const subscriptionId = subscriptionIds[chainId];
50
54
  const slotId = 0;
51
55
  const callbackGasLimit = 300_000;
52
- const consumerContract = new ethers5_1.ethers.Contract(contractAddress, contractAbi, signerV5);
53
- const linkTokenAddress = network.linkToken;
54
- const functionsRouterAddress = network.functionsRouter;
55
- const subscriptionManager = new functions_toolkit_1.SubscriptionManager({
56
- // Use the v5 signer here (toolkit expects ethers v5 types)
57
- signer: signerV5,
58
- linkTokenAddress,
59
- functionsRouterAddress,
60
- });
61
- await subscriptionManager.initialize();
62
- const donId = network.donId;
63
- const secretsManager = new functions_toolkit_1.SecretsManager({
64
- // ethers v5 signer again
65
- signer: signerV5,
66
- functionsRouterAddress,
67
- donId,
68
- });
69
- await secretsManager.initialize();
56
+ const consumerContract = new ethers_1.ethers.Contract(contractAddress, contractAbi, signer);
57
+ // const linkTokenAddress = network.linkToken;
58
+ const functionsRouterAddress = networkConfig.functionsRouter;
59
+ const { chain, network } = decomposeFromChainId(chainId);
60
+ const subscriptionManager = new ChainlinkFunctionConnector(signer, { chain, network });
61
+ const secretsManager = new ChainlinkSecretsConnector(signer, { chain, network });
70
62
  const subInfo = await subscriptionManager.getSubscriptionInfo(subscriptionId);
71
63
  if (!subInfo.consumers
72
64
  .map((c) => c.toLowerCase())
73
65
  .includes(contractAddress.toLowerCase())) {
74
66
  throw Error(`Consumer contract ${contractAddress} has not been added to subscription ${subscriptionId}`);
75
67
  }
76
- // Use the v5 provider for gas data (to avoid type mismatches)
77
- const { gasPrice } = await signerV5.provider.getFeeData();
68
+ const { gasPrice } = await signer.provider.getFeeData();
78
69
  // @ts-ignore
79
- const gasPriceWei = BigInt(Math.ceil(ethers5_1.ethers.utils.formatUnits(gasPrice, "wei").toString()));
70
+ const gasPriceWei = BigInt(Math.ceil(ethers_1.ethers.formatUnits(gasPrice, "wei").toString()));
80
71
  const estimatedCostJuels = await subscriptionManager.estimateFunctionsRequestCost({
81
- donId,
72
+ donId: subscriptionManager.donId,
82
73
  subscriptionId,
83
74
  callbackGasLimit,
84
75
  gasPriceWei,
85
76
  });
86
- const estimatedCostLink = ethers5_1.ethers.utils.formatUnits(estimatedCostJuels.toString(), 18);
87
- const subBalanceLink = ethers5_1.ethers.utils.formatUnits(subInfo.balance.toString(), 18);
77
+ const estimatedCostLink = ethers_1.ethers.formatUnits(estimatedCostJuels.toString(), 18);
78
+ const subBalanceLink = ethers_1.ethers.parseUnits(subInfo.balance.toString(), 18);
88
79
  if (subInfo.balance <= estimatedCostJuels) {
89
80
  throw Error(`Subscription ${subscriptionId} does not have sufficient funds. The estimated cost is ${estimatedCostLink} LINK, but the subscription only has ${subBalanceLink} LINK.`);
90
81
  }
@@ -100,11 +91,11 @@ async function request(chainId, signerV5) {
100
91
  slotId,
101
92
  version,
102
93
  });
103
- const responseListener = new functions_toolkit_1.ResponseListener({
104
- provider: signerV5.provider,
94
+ const responseListener = new ResponseListener({
95
+ provider: signer.provider,
105
96
  functionsRouterAddress,
106
97
  });
107
- console.log(`Waiting for transaction for RAACPrimeRateOracle contract ${contractAddress} on network ${network.name} to be confirmed...`);
98
+ console.log(`Waiting for transaction for RAACPrimeRateOracle contract ${contractAddress} on network ${networkConfig.name} to be confirmed...`);
108
99
  const overrides = {
109
100
  gasLimit: 1_500_000,
110
101
  };
@@ -115,13 +106,13 @@ async function request(chainId, signerV5) {
115
106
  try {
116
107
  // localFunctionsTestnet needs 0 or 1 confirmations to work correctly as it's local.
117
108
  // If on live testnet or mainnet, setting to undefined then uses the functions-toolkit default of 2 confirmations.
118
- const NUM_CONFIRMATIONS = network.confirmations;
109
+ const NUM_CONFIRMATIONS = networkConfig.confirmations;
119
110
  // Get response data
120
111
  const { requestId, totalCostInJuels, responseBytesHexstring, errorString, fulfillmentCode, } = await responseListener.listenForResponseFromTransaction(requestTx.hash, undefined, NUM_CONFIRMATIONS, undefined);
121
112
  switch (fulfillmentCode) {
122
- case functions_toolkit_1.FulfillmentCode.FULFILLED:
113
+ case FulfillmentCode.FULFILLED:
123
114
  if (responseBytesHexstring !== "0x") {
124
- console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
115
+ console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
125
116
  }
126
117
  else if (errorString.length > 0) {
127
118
  console.error(`Request ${requestId} fulfilled with error: ${errorString}\n`);
@@ -129,13 +120,13 @@ async function request(chainId, signerV5) {
129
120
  else {
130
121
  console.warn(`Request ${requestId} fulfilled with empty response data.\n`);
131
122
  }
132
- const linkCost = ethers5_1.ethers.utils.formatUnits(totalCostInJuels.toString(), 18);
123
+ const linkCost = ethers_1.ethers.formatUnits(totalCostInJuels.toString(), 18);
133
124
  console.log(`Total request cost: ${linkCost + " LINK"}`);
134
125
  break;
135
- case functions_toolkit_1.FulfillmentCode.USER_CALLBACK_ERROR:
126
+ case FulfillmentCode.USER_CALLBACK_ERROR:
136
127
  console.error("Error encountered when calling consumer contract callback.\nEnsure the fulfillRequest function in RAACPrimeRateOracle is correct and the --callbackgaslimit is sufficient.");
137
128
  break;
138
- case functions_toolkit_1.FulfillmentCode.COST_EXCEEDS_COMMITMENT:
129
+ case FulfillmentCode.COST_EXCEEDS_COMMITMENT:
139
130
  console.error(`Request ${requestId} failed due to a gas price spike when attempting to respond.`);
140
131
  break;
141
132
  default:
@@ -4,19 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.simulate = simulate;
7
- const functions_toolkit_1 = require("@chainlink/functions-toolkit");
7
+ const chainlinkjs_1 = require("@raac/chainlinkjs");
8
+ const { simulateScript, decodeResult } = chainlinkjs_1.utils;
8
9
  const config_1 = __importDefault(require("./config"));
9
10
  async function simulate() {
10
11
  // Simulate the request first
11
12
  const sourceFetch = await fetch(config_1.default.sourceURL);
12
13
  const source = await sourceFetch.text();
13
14
  console.log("Reading source from URL: ", config_1.default.sourceURL);
14
- const { responseBytesHexstring, errorString } = await (0, functions_toolkit_1.simulateScript)({
15
+ const { responseBytesHexstring, errorString } = await simulateScript({
15
16
  ...config_1.default,
16
17
  source,
17
18
  });
18
19
  if (responseBytesHexstring) {
19
- console.log(`\nResponse returned by script during local simulation: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
20
+ console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
20
21
  }
21
22
  if (errorString) {
22
23
  console.log(`\nError returned by simulated script:\n${errorString}\n`);
@@ -4,10 +4,11 @@ const _helpers_1 = require("./_helpers");
4
4
  async function getRWAVaultInfo(chainId, provider) {
5
5
  try {
6
6
  const rwaVaultContract = await (0, _helpers_1.getRWAVaultContract)(chainId, provider);
7
- const [totalAssets, pricePerShare, vaultToken, stabilityPool, vrfConsumer, indexTokenMintingFee, feeCollector, vrfRequestDelay, allowVRFRequest,] = await Promise.all([
7
+ const [totalAssets, pricePerShare, vaultToken, underlyingAssetToken, stabilityPool, vrfConsumer, indexTokenMintingFee, feeCollector, vrfRequestDelay, allowVRFRequest,] = await Promise.all([
8
8
  rwaVaultContract.totalAssets(),
9
9
  rwaVaultContract.pricePerShare(),
10
10
  rwaVaultContract.vaultToken(),
11
+ rwaVaultContract.underlyingAssetToken(),
11
12
  rwaVaultContract.stabilityPool(),
12
13
  rwaVaultContract.vrfConsumer(),
13
14
  rwaVaultContract.indexTokenMintingFee(),
@@ -19,6 +20,7 @@ async function getRWAVaultInfo(chainId, provider) {
19
20
  totalAssets: totalAssets.toString(),
20
21
  pricePerShare: pricePerShare.toString(),
21
22
  vaultToken,
23
+ underlyingAssetToken,
22
24
  stabilityPool,
23
25
  vrfConsumer,
24
26
  indexTokenMintingFee: indexTokenMintingFee.toString(),
@@ -10,8 +10,7 @@ const RPCLibrary_1 = __importDefault(require("../RPCLibrary"));
10
10
  const contracts_1 = require("../utils/contracts");
11
11
  const artifacts_1 = require("../utils/artifacts");
12
12
  const _helpers_1 = require("../pools/rwaVault/_helpers");
13
- const ethers5_1 = require("ethers5");
14
- const chainId = 11155111;
13
+ const chainId = 8453;
15
14
  const config = chains_1.default[chainId];
16
15
  const TEST_MNEMONIC = process.env.TEST_MNEMONIC;
17
16
  const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY;
@@ -61,8 +60,8 @@ async function setup() {
61
60
  const StabilityPoolAddress = (0, contracts_1.getContractAddress)(chainId, "stabilitypool");
62
61
  const StabilityPoolABI = (0, artifacts_1.getABI)("stabilitypool");
63
62
  const StabilityPoolContract = new ethers_1.ethers.Contract(StabilityPoolAddress, StabilityPoolABI, signer);
64
- const providerV5 = new ethers5_1.ethers.providers.JsonRpcProvider(config.rpcs[0]);
65
- const signerV5 = new ethers5_1.ethers.Wallet(TEST_PRIVATE_KEY, providerV5);
63
+ // const provider = new ethers.JsonRpcProvider(config.rpcs[0]);
64
+ const signerPrivateKey = new ethers_1.ethers.Wallet(TEST_PRIVATE_KEY, provider);
66
65
  const TreasuryAddress = (0, contracts_1.getContractAddress)(chainId, "treasury");
67
66
  const TreasuryABI = (0, artifacts_1.getABI)("treasury");
68
67
  const TreasuryContract = new ethers_1.ethers.Contract(TreasuryAddress, TreasuryABI, signer);
@@ -140,12 +139,6 @@ async function setup() {
140
139
  // console.log(tx);
141
140
  // let tx = await StabilityPoolContract.setLiquidationVaultTokenSplit(2_50, 2_50, 90_00, 5_00)
142
141
  // await tx.wait();
143
- // console.log(await raacNFTContract.hasRole(await raacNFTContract.ADMIN_ROLE(), signer.address))
144
- console.log(await housePriceContract.oracle());
145
- // await (await housePriceContract.setOracle(signer.address)).wait();
146
- // return;
147
- await (await housePriceContract.setHousePrice("8", ethers_1.ethers.parseEther("63500"))).wait();
148
- return;
149
142
  await (await RWAVaultContract.registerDepositableAdapter("0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44")).wait();
150
143
  // // console.log(await rpc.wallet.assets.getBalance(chainId, "rwaindextoken", signer.address, provider))
151
144
  // // set the base uri to instruxi data gateway
@@ -9,7 +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 chainId = 11155111;
12
+ const chainId = 8453;
13
13
  const config = chains_1.default[chainId];
14
14
  const TEST_MNEMONIC = process.env.TEST_MNEMONIC;
15
15
  const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY;
@@ -53,43 +53,27 @@ async function setupLiquidityPool() {
53
53
  rpc.address = signer.address;
54
54
  rpc.provider = provider;
55
55
  rpc.chainId = chainId;
56
- const MockLiquidityPoolAddress = "0x0cAa0daa4f5EC8934428Ae406965B044f42F7D49";
56
+ const MockLiquidityPoolAddress = "0x9E545E3C0baAB3E08CdfD552C960A1050f373042";
57
57
  const MockLiquidityPoolABI = [
58
58
  "function add_liquidity(uint256[2] amounts, uint256 min_mint_amount, address receiver) external",
59
59
  ];
60
60
  const MockLiquidityPoolContract = new ethers_1.ethers.Contract(MockLiquidityPoolAddress, MockLiquidityPoolABI, signer);
61
- // mint 200 million in crvusd
61
+ // mint 10 million in crvusd
62
62
  console.log("Minting 100 million in crvusd");
63
- await rpc.wallet.assets.mintAsset(chainId, "crvusd", 9800000n, signer.address, signer);
64
- // deposit 100 million in the RWA Vault
65
- // console.log("Depositing 5 million in the RWA Vault");
66
- // await rpc.wallet.assets.approveAsset(
67
- // chainId,
68
- // "crvusd",
69
- // await rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter")
70
- // .address,
71
- // "100000000",
72
- // signer
73
- // );
74
- // const d1 = new ethers.AbiCoder().encode(
75
- // ["uint256"],
76
- // [ethers.parseEther("5000000")]
77
- // );
78
- // await rpc.pools.rwaVault.depositToRWAVault(
79
- // chainId,
80
- // "crvusdadapter",
81
- // d1,
82
- // signer.address,
83
- // "0",
84
- // signer
85
- // );
86
- // deposit 100 million in the Mock Liquidity Pool
63
+ await rpc.wallet.assets.mintAsset(chainId, "crvusd", 200000000n, signer.address, signer);
64
+ // deposit 5 million in the RWA Vault
65
+ console.log("Depositing 5 million in the RWA Vault");
66
+ await rpc.wallet.assets.approveAsset(chainId, "crvusd", await rpc.pools.rwaVault.getAdapterAddress(chainId, "crvusdadapter")
67
+ .address, "100000000", signer);
68
+ const d1 = new ethers_1.ethers.AbiCoder().encode(["uint256"], [ethers_1.ethers.parseEther("100000000")]);
69
+ await rpc.pools.rwaVault.depositToRWAVault(chainId, "crvusdadapter", d1, signer.address, "0", signer);
70
+ // deposit 5 million in the Mock Liquidity Pool
87
71
  console.log("Depositing 5 million in the Mock Liquidity Pool");
88
- await rpc.wallet.assets.approveAsset(chainId, "crvusd", MockLiquidityPoolAddress, "9800000", signer);
72
+ await rpc.wallet.assets.approveAsset(chainId, "crvusd", MockLiquidityPoolAddress, "100000000", signer);
89
73
  const indextokenBalance = (await rpc.wallet.assets.getBalance(chainId, "rwaindextoken", signer.address, provider)).balance;
90
74
  await rpc.wallet.assets.approveAsset(chainId, "rwaindextoken", MockLiquidityPoolAddress, indextokenBalance, signer);
91
75
  await (await MockLiquidityPoolContract.add_liquidity([
92
- ethers_1.ethers.parseEther("9800000"),
76
+ ethers_1.ethers.parseEther("100000000"),
93
77
  ethers_1.ethers.parseEther(indextokenBalance.toString()),
94
78
  ], 0, signer.address)).wait();
95
79
  return;
@@ -1,5 +1,5 @@
1
- import { Signer } from "ethers5";
2
- export declare function encryptSecretURLs(chainId: number, urls: string[], signerV5: Signer): Promise<{
3
- encryptedSecrets: string;
4
- isVerified: true;
1
+ import { Signer } from 'ethers';
2
+ export declare function encryptSecretURLs(chainId: number, urls: string[], signer: Signer): Promise<{
3
+ encryptedSecrets: any;
4
+ isVerified: any;
5
5
  }>;
@@ -1,4 +1,2 @@
1
- import { Signer } from "ethers5";
2
- export declare function encryptSecrets(chainId: number, secrets: Record<string, string>, outputFile: string, signerV5: Signer): Promise<{
3
- encryptedSecrets: string;
4
- }>;
1
+ import { Signer } from "ethers";
2
+ export declare function encryptSecrets(chainId: number, secrets: Record<string, string>, outputFile: string, signer: Signer): Promise<any>;