@raac/rpc 1.1.0-beta.57 → 1.1.0-beta.58

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.
@@ -121,8 +121,8 @@ const getWithdrawRequestInfo_2 = require("./pools/stabilityPool/getWithdrawReque
121
121
  const requestWithdraw_2 = require("./pools/stabilityPool/requestWithdraw");
122
122
  const artifacts_1 = require("./utils/artifacts");
123
123
  const errorDecoder_1 = require("./utils/errorDecoder");
124
- const request_1 = require("./oracles/prime-rate/request");
125
- const request_2 = require("./oracles/houses/request");
124
+ // import { request as requestPrimeRate } from "./oracles/prime-rate/request";
125
+ // import { request as requestHousePrices } from "./oracles/houses/request";
126
126
  class RPCLibrary {
127
127
  signer;
128
128
  isConnected;
@@ -133,7 +133,14 @@ class RPCLibrary {
133
133
  assets;
134
134
  // valid
135
135
  wallet;
136
- oracles;
136
+ // oracles: {
137
+ // primeRate: {
138
+ // request: typeof requestPrimeRate;
139
+ // };
140
+ // housePrices: {
141
+ // request: typeof requestHousePrices;
142
+ // };
143
+ // };
137
144
  nfts;
138
145
  contracts;
139
146
  pools;
@@ -294,14 +301,14 @@ class RPCLibrary {
294
301
  decodeErrorMessage: errorDecoder_1.decodeErrorMessage,
295
302
  attachDecodedErrorMessage: errorDecoder_1.attachDecodedErrorMessage,
296
303
  };
297
- this.oracles = {
298
- primeRate: {
299
- request: request_1.request,
300
- },
301
- housePrices: {
302
- request: request_2.request,
303
- },
304
- };
304
+ // this.oracles = {
305
+ // primeRate: {
306
+ // request: requestPrimeRate,
307
+ // },
308
+ // housePrices: {
309
+ // request: requestHousePrices,
310
+ // },
311
+ // };
305
312
  }
306
313
  async getWallet(privateKey, provider) {
307
314
  // @ts-ignore
@@ -15,6 +15,7 @@ async function getStabilityPoolInfo(chainId, address, provider) {
15
15
  }
16
16
  throw error;
17
17
  };
18
+ console.log(await stabilityPoolContract.deToken());
18
19
  // Fetch data from StabilityPool
19
20
  const [totalDeposits] = await Promise.all([
20
21
  stabilityPoolContract
@@ -29,9 +30,29 @@ async function getStabilityPoolInfo(chainId, address, provider) {
29
30
  .catch(handleError("getUserDeposit")),
30
31
  ]);
31
32
  }
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
+ }
32
52
  const result = {
33
53
  totalDeposits: ethers_1.ethers.formatEther(totalDeposits ?? 0n),
34
54
  userDeposit: ethers_1.ethers.formatEther(userDeposit ?? 0n),
55
+ apy: parseFloat((apy ?? 0n).toString()) / 100, // APY in percentage
35
56
  };
36
57
  return result;
37
58
  }
@@ -96,8 +96,6 @@ import { getWithdrawRequestInfo as getStabilityPoolWithdrawRequestInfo } from ".
96
96
  import { requestWithdraw as requestStabilityPoolWithdraw } from "./pools/stabilityPool/requestWithdraw";
97
97
  import { getABI } from "./utils/artifacts";
98
98
  import { decodeErrorName, getErrorInfo, attachDecodedError, decodeErrorMessage, attachDecodedErrorMessage } from "./utils/errorDecoder";
99
- import { request as requestPrimeRate } from "./oracles/prime-rate/request";
100
- import { request as requestHousePrices } from "./oracles/houses/request";
101
99
  declare class RPCLibrary {
102
100
  signer: Signer | null;
103
101
  isConnected: boolean;
@@ -122,14 +120,6 @@ declare class RPCLibrary {
122
120
  };
123
121
  rpcs: {};
124
122
  };
125
- oracles: {
126
- primeRate: {
127
- request: typeof requestPrimeRate;
128
- };
129
- housePrices: {
130
- request: typeof requestHousePrices;
131
- };
132
- };
133
123
  nfts: {
134
124
  getBaseUri: typeof getBaseUri;
135
125
  mint: typeof mintNFT;
@@ -3,5 +3,6 @@ import { ChainId } from "../../configs/chains/index";
3
3
  declare function getStabilityPoolInfo(chainId: ChainId, address: string, provider: Provider): Promise<{
4
4
  totalDeposits: string;
5
5
  userDeposit: string;
6
+ apy: number;
6
7
  }>;
7
8
  export default getStabilityPoolInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raac/rpc",
3
- "version": "1.1.0-beta.57",
3
+ "version": "1.1.0-beta.58",
4
4
  "description": "RPC Library for RAAC ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",