@raac/rpc 1.1.0-beta.50 → 1.1.0-beta.51
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.
|
@@ -40,18 +40,24 @@ async function getLendingPoolInfo(chainId, userAddress, provider) {
|
|
|
40
40
|
const optimalUtilizationRate = rateData?.optimalUtilizationRate ?? 0n;
|
|
41
41
|
const protocolFeeRate = rateData?.protocolFeeRate ?? 0n;
|
|
42
42
|
// Compute APY
|
|
43
|
-
let
|
|
43
|
+
let apr;
|
|
44
44
|
if (utilization <= optimalUtilizationRate && optimalUtilizationRate > 0) {
|
|
45
|
-
|
|
45
|
+
apr = optimalRate;
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
const excessUtilization = utilization - optimalUtilizationRate;
|
|
49
49
|
const maxExcessUtilization = BigInt(1e27) - optimalUtilizationRate;
|
|
50
50
|
const rateSlope = maxRate - optimalRate;
|
|
51
51
|
const rateIncrease = (excessUtilization * rateSlope) / maxExcessUtilization;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
apr = primeRate + rateIncrease;
|
|
53
|
+
apr = apr > maxRate ? maxRate : apr;
|
|
54
54
|
}
|
|
55
|
+
// compute the APY
|
|
56
|
+
let apy;
|
|
57
|
+
const grossLiquidityRate = utilization * currentUsageRate / BigInt(1e27);
|
|
58
|
+
const protocolFeeAmount = grossLiquidityRate * protocolFeeRate / BigInt(1e27);
|
|
59
|
+
apy = grossLiquidityRate - protocolFeeAmount;
|
|
60
|
+
console.log("apr", apy);
|
|
55
61
|
let userRedeemable = 0n;
|
|
56
62
|
if (userAddress) {
|
|
57
63
|
// Fetch user's scaled RToken balance
|
|
@@ -82,6 +88,7 @@ async function getLendingPoolInfo(chainId, userAddress, provider) {
|
|
|
82
88
|
normalizedDebt: (Number(normalizedDebt.toString()) / 1e27).toFixed(6),
|
|
83
89
|
apy: (Number(apy.toString()) / 1e25).toFixed(2),
|
|
84
90
|
userRedeemable: ethers_1.ethers.formatEther(userRedeemable ?? 0n),
|
|
91
|
+
apr: (Number(apr.toString()) / 1e25).toFixed(2),
|
|
85
92
|
};
|
|
86
93
|
return result;
|
|
87
94
|
}
|
package/dist/scripts/index.js
CHANGED
|
@@ -10,7 +10,6 @@ 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 request_1 = require("../oracles/prime-rate/request");
|
|
14
13
|
const chainId = 11155111;
|
|
15
14
|
const config = chains_1.default[chainId];
|
|
16
15
|
const TEST_MNEMONIC = process.env.TEST_MNEMONIC;
|
|
@@ -43,11 +42,15 @@ async function setup() {
|
|
|
43
42
|
const RAACPrimeRateOracleAddress = (0, contracts_1.getContractAddress)(chainId, "raacprimerateoracle");
|
|
44
43
|
const RAACPrimeRateOracleABI = (0, artifacts_1.getABI)("raacprimerateoracle");
|
|
45
44
|
const RAACPrimeRateOracleContract = new ethers_1.ethers.Contract(RAACPrimeRateOracleAddress, RAACPrimeRateOracleABI, signer);
|
|
46
|
-
await (0, request_1.request)(chainId, "us", TEST_PRIVATE_KEY);
|
|
47
45
|
const LendingPoolAddress = (0, contracts_1.getContractAddress)(chainId, "lendingpool");
|
|
48
46
|
const LendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
49
47
|
const LendingPoolContract = new ethers_1.ethers.Contract(LendingPoolAddress, LendingPoolABI, signer);
|
|
50
|
-
|
|
48
|
+
// await request(chainId, "us", TEST_PRIVATE_KEY)
|
|
49
|
+
const housePriceAddress = (0, contracts_1.getContractAddress)(chainId, "raachouseprices");
|
|
50
|
+
const housePriceABI = (0, artifacts_1.getABI)("raachouseprices");
|
|
51
|
+
const housePriceContract = new ethers_1.ethers.Contract(housePriceAddress, housePriceABI, signer);
|
|
52
|
+
console.log(await rpc.pools.lendingPool.getLendingPoolInfo(chainId, signer.address, provider));
|
|
53
|
+
// console.log(await LendingPoolContract.rateData())
|
|
51
54
|
return;
|
|
52
55
|
// Add funds in the Mock Liquidity Pool
|
|
53
56
|
const CURVE_POOL_ADDRESSES = {
|
|
@@ -98,19 +101,11 @@ async function setup() {
|
|
|
98
101
|
if (chainId !== 8453) {
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
101
|
-
const RAACHousePriceOracleAddress = "0xce7b34BEE3E58502106b07b20b4E3a229c22516a";
|
|
102
|
-
const RAACHousePriceOracleABI = (0, artifacts_1.getABI)("raachousepriceoracle");
|
|
103
|
-
const RAACHousePriceOracleContract = new ethers_1.ethers.Contract(RAACHousePriceOracleAddress, RAACHousePriceOracleABI, signer);
|
|
104
|
-
//
|
|
105
104
|
console.log(await rpc.pools.lendingPool.getLendingPoolInfo(chainId, signer.address, provider));
|
|
106
105
|
console.log(await rpc.wallet.assets.getBalance(chainId, "rtoken", signer.address, provider));
|
|
107
106
|
console.log(await rpc.nfts.getTokensByOwner(chainId, signer.address, provider));
|
|
108
107
|
// // // set the oracle address of the RAACHousePrice. TEmporarily simulating that I AM THE ORACLE
|
|
109
108
|
await rpc.contracts.housePrices.setOracle(chainId, signer.address, signer);
|
|
110
|
-
// // // // // set price for 3 houses
|
|
111
|
-
const housePriceAddress = (0, contracts_1.getContractAddress)(chainId, "raachouseprices");
|
|
112
|
-
const housePriceABI = (0, artifacts_1.getABI)("raachouseprices");
|
|
113
|
-
const housePriceContract = new ethers_1.ethers.Contract(housePriceAddress, housePriceABI, signer);
|
|
114
109
|
const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
|
|
115
110
|
const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
|
|
116
111
|
const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, signer);
|