@raac/rpc 1.1.0-beta.58 → 1.1.0-beta.59
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.
|
@@ -15,7 +15,6 @@ async function getStabilityPoolInfo(chainId, address, provider) {
|
|
|
15
15
|
}
|
|
16
16
|
throw error;
|
|
17
17
|
};
|
|
18
|
-
console.log(await stabilityPoolContract.deToken());
|
|
19
18
|
// Fetch data from StabilityPool
|
|
20
19
|
const [totalDeposits] = await Promise.all([
|
|
21
20
|
stabilityPoolContract
|
|
@@ -30,29 +29,9 @@ async function getStabilityPoolInfo(chainId, address, provider) {
|
|
|
30
29
|
.catch(handleError("getUserDeposit")),
|
|
31
30
|
]);
|
|
32
31
|
}
|
|
33
|
-
// Fetch RAAC Minter information if needed for APY calculation
|
|
34
|
-
const raacMinterAddress = (0, contracts_1.getContractAddress)(chainId, "raacminter");
|
|
35
|
-
let apy = 0n;
|
|
36
|
-
if (raacMinterAddress && raacMinterAddress !== ethers_1.ethers.ZeroAddress) {
|
|
37
|
-
const raacMinterABI = (0, artifacts_1.getABI)("raacminter");
|
|
38
|
-
const raacMinterContract = new ethers_1.ethers.Contract(raacMinterAddress, raacMinterABI, provider);
|
|
39
|
-
const [emissionRate, totalSupply] = await Promise.all([
|
|
40
|
-
raacMinterContract.emissionRate().catch(handleError("emissionRate")),
|
|
41
|
-
raacMinterContract
|
|
42
|
-
.getTotalSupply()
|
|
43
|
-
.catch(handleError("getTotalSupply")),
|
|
44
|
-
]);
|
|
45
|
-
// APY Calculation
|
|
46
|
-
// Assuming emissionRate is per block and BLOCKS_PER_YEAR is known
|
|
47
|
-
const BLOCKS_PER_YEAR = 2102400n; // Approximate number of blocks per year (Ethereum ~15 sec/block)
|
|
48
|
-
const emissionRatePerYear = emissionRate * BLOCKS_PER_YEAR;
|
|
49
|
-
apy =
|
|
50
|
-
totalSupply > 0n ? (emissionRatePerYear * 10000n) / totalSupply : 0n;
|
|
51
|
-
}
|
|
52
32
|
const result = {
|
|
53
33
|
totalDeposits: ethers_1.ethers.formatEther(totalDeposits ?? 0n),
|
|
54
34
|
userDeposit: ethers_1.ethers.formatEther(userDeposit ?? 0n),
|
|
55
|
-
apy: parseFloat((apy ?? 0n).toString()) / 100, // APY in percentage
|
|
56
35
|
};
|
|
57
36
|
return result;
|
|
58
37
|
}
|