@raac/rpc 1.1.0-beta.50 → 1.1.0-beta.52
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.
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"raachouseprices": {
|
|
18
18
|
"id": "raachouseprices",
|
|
19
19
|
"name": "RAAC House Prices",
|
|
20
|
-
"contract": "
|
|
20
|
+
"contract": "0x3a933ab12852a30c83dFDeAEf4a67b84241B0acc"
|
|
21
21
|
},
|
|
22
22
|
"auctionfactory": {
|
|
23
23
|
"id": "auctionfactory",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"feecollector": {
|
|
38
38
|
"id": "feecollector",
|
|
39
39
|
"name": "Fee Collector",
|
|
40
|
-
"contract": "
|
|
40
|
+
"contract": "0x08831baeC732C9a47C18016c1A9A17611e0B903d"
|
|
41
41
|
},
|
|
42
42
|
"treasury": {
|
|
43
43
|
"id": "treasury",
|
|
44
44
|
"name": "Treasury",
|
|
45
|
-
"contract": "
|
|
45
|
+
"contract": "0xfDD625D9E062ff2b31eBe9130162B775d3975e49"
|
|
46
46
|
},
|
|
47
47
|
"repairfund": {
|
|
48
48
|
"id": "repairfund",
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"rwavault": {
|
|
58
58
|
"id": "rwavault",
|
|
59
59
|
"name": "RWA Vault",
|
|
60
|
-
"contract": "
|
|
60
|
+
"contract": "0x4e41b7d32D2AeD257e479a9d76ee00A3F38Cf38E"
|
|
61
61
|
},
|
|
62
62
|
"complianceregistry": {
|
|
63
63
|
"id": "complianceregistry",
|
|
64
64
|
"name": "Compliance Registry",
|
|
65
|
-
"contract": "
|
|
65
|
+
"contract": "0x7Cc1CA23F8fff6B51074131140e0928Df7043633"
|
|
66
66
|
},
|
|
67
67
|
"rwaindextokencollector": {
|
|
68
68
|
"id": "rwaindextokencollector",
|
|
69
69
|
"name": "RWA Index Token Collector",
|
|
70
|
-
"contract": "
|
|
70
|
+
"contract": "0x958faB88A3adD2c76870F1ca4c5dC8042bFB860f"
|
|
71
71
|
},
|
|
72
72
|
"raactokencollector": {
|
|
73
73
|
"id": "raactokencollector",
|
|
@@ -77,31 +77,31 @@
|
|
|
77
77
|
"raachousepriceoracle": {
|
|
78
78
|
"id": "raachousepriceoracle",
|
|
79
79
|
"name": "RAAC House Price Oracle",
|
|
80
|
-
"contract": "
|
|
80
|
+
"contract": "0x7Ff66b2700c5F75fcD17c810e17E948276C11aA3"
|
|
81
81
|
},
|
|
82
82
|
"raacprimerateoracle": {
|
|
83
83
|
"id": "raacprimerateoracle",
|
|
84
84
|
"name": "RAAC Prime Rate Oracle",
|
|
85
|
-
"contract": "
|
|
85
|
+
"contract": "0x3c3Daa41c3Cf41d51AE2a56749D673C73DE04A6B"
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"pools": {
|
|
89
89
|
"stabilitypool": {
|
|
90
90
|
"id": "stabilitypool",
|
|
91
91
|
"name": "Stability Pool",
|
|
92
|
-
"contract": "
|
|
92
|
+
"contract": "0x2Aada221CAC2A2366407792CDD47924f7F75D232"
|
|
93
93
|
},
|
|
94
94
|
"lendingpool": {
|
|
95
95
|
"id": "lendingpool",
|
|
96
96
|
"name": "Lending Pool",
|
|
97
|
-
"contract": "
|
|
97
|
+
"contract": "0x039C516918D76F0e508E3AeF404a1a0193903A94"
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
"nfts": {
|
|
101
101
|
"raacnft": {
|
|
102
102
|
"id": "raacnft",
|
|
103
103
|
"name": "RAAC NFT",
|
|
104
|
-
"contract": "
|
|
104
|
+
"contract": "0x9f732c8082a660a89A55ec7551d90393572F5d42"
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
"assets": {
|
|
@@ -115,43 +115,43 @@
|
|
|
115
115
|
"id": "crvusd",
|
|
116
116
|
"name": "CRVUSD",
|
|
117
117
|
"decimals": 18,
|
|
118
|
-
"contract": "
|
|
118
|
+
"contract": "0xd39d5D3289B6B76D4d584a9cD58AED99442D29eb"
|
|
119
119
|
},
|
|
120
120
|
"rtoken": {
|
|
121
121
|
"id": "rtoken",
|
|
122
122
|
"name": "RToken",
|
|
123
123
|
"decimals": 18,
|
|
124
|
-
"contract": "
|
|
124
|
+
"contract": "0x3fea2bF12b686FfFD0321DA6CA6c762FA7C2121C"
|
|
125
125
|
},
|
|
126
126
|
"detoken": {
|
|
127
127
|
"id": "detoken",
|
|
128
128
|
"name": "DEToken",
|
|
129
129
|
"decimals": 18,
|
|
130
|
-
"contract": "
|
|
130
|
+
"contract": "0xdCB4C5aB4aE4873ec700C3EACD1f338547cE6117"
|
|
131
131
|
},
|
|
132
132
|
"raactoken": {
|
|
133
133
|
"id": "raactoken",
|
|
134
134
|
"name": "RAAC",
|
|
135
135
|
"decimals": 18,
|
|
136
|
-
"contract": "
|
|
136
|
+
"contract": "0xc16A8e97189757f7A614E76b3C88fbDf09Beb405"
|
|
137
137
|
},
|
|
138
138
|
"veraac": {
|
|
139
139
|
"id": "veraac",
|
|
140
140
|
"name": "VERAAC",
|
|
141
141
|
"decimals": 18,
|
|
142
|
-
"contract": "
|
|
142
|
+
"contract": "0x68747860f7576CeF1bd68F8eC1853c2191edB949"
|
|
143
143
|
},
|
|
144
144
|
"debttoken": {
|
|
145
145
|
"id": "debttoken",
|
|
146
146
|
"name": "Debt Token",
|
|
147
147
|
"decimals": 18,
|
|
148
|
-
"contract": "
|
|
148
|
+
"contract": "0x6f81d033a6F87d987851086cf44214D6c0730089"
|
|
149
149
|
},
|
|
150
150
|
"rwaindextoken": {
|
|
151
151
|
"id": "rwaindextoken",
|
|
152
152
|
"name": "RWA Index Token",
|
|
153
153
|
"decimals": 18,
|
|
154
|
-
"contract": "
|
|
154
|
+
"contract": "0xc23b30B0fd654f51e6b833d3d550c320c0f32018"
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
"adapters": {
|
|
@@ -159,13 +159,13 @@
|
|
|
159
159
|
"raacnftadapter": {
|
|
160
160
|
"id": "raacnftadapter",
|
|
161
161
|
"name": "RAAC NFT Adapter",
|
|
162
|
-
"contract": "
|
|
162
|
+
"contract": "0x8DCc5f781933A6232d7aA6003cb5b07138B7A8AA",
|
|
163
163
|
"type": "ERC721"
|
|
164
164
|
},
|
|
165
165
|
"rwaindextokenadapter": {
|
|
166
166
|
"id": "rwaindextokenadapter",
|
|
167
167
|
"name": "RWA Index Token",
|
|
168
|
-
"contract": "
|
|
168
|
+
"contract": "0x204B3Cfe37734F80C73958c9C188d23ec120C1d5",
|
|
169
169
|
"type": "ERC20"
|
|
170
170
|
}
|
|
171
171
|
},
|
|
@@ -173,13 +173,13 @@
|
|
|
173
173
|
"raacnftadapter": {
|
|
174
174
|
"id": "raacnftadapter",
|
|
175
175
|
"name": "RAAC NFT Adapter",
|
|
176
|
-
"contract": "
|
|
176
|
+
"contract": "0x0C45430F37ce079740b55B323c090b3B498DBdf0",
|
|
177
177
|
"type": "ERC721"
|
|
178
178
|
},
|
|
179
179
|
"crvusdadapter": {
|
|
180
180
|
"id": "crvusdadapter",
|
|
181
181
|
"name": "CRVUSD Adapter",
|
|
182
|
-
"contract": "
|
|
182
|
+
"contract": "0x0a72162CF100A5494Ca8593a8c1A906Ff8349CAB",
|
|
183
183
|
"type": "ERC20"
|
|
184
184
|
}
|
|
185
185
|
}
|
|
@@ -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);
|