Skip to content

Commit 5d9cc38

Browse files
committed
rename resolv
1 parent b03abd0 commit 5d9cc38

File tree

3 files changed

+102
-118
lines changed

3 files changed

+102
-118
lines changed

src/adaptors/meteora/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const standardPools = 'https://app.meteora.ag/amm/pools/v1?page=0&size=100';
2+
const clPools =
3+
'https://app.meteora.ag/clmm-api/pair/all_by_groups?page=0&limit=100&unknown=true&sort_key=volume&order_by=desc';
4+
5+
const apy = async () => {
6+
const response = await fetch(standardPools);
7+
const data = await response.json();
8+
return data.data.map((pool) => {
9+
return {
10+
pool: pool.pool_address,
11+
chain: 'Solana',
12+
project: 'meteora',
13+
symbol: pool.pool_name,
14+
underlyingTokens: p.pool_token_mints,
15+
tvlUsd: pool.pool_tvl,
16+
apyBase: pool.day.feeApr,
17+
apyReward,
18+
rewardTokens:
19+
apyReward > 0
20+
? pool?.rewardDefaultInfos?.map((r) => r.mint?.address)
21+
: [],
22+
apyBase7d: pool.week.feeApr,
23+
volumeUsd1d: pool.day.volume,
24+
volumeUsd7d: pool.week.volume,
25+
poolMeta: `${pool.type} - ${pool.feeRate * 100}%`,
26+
url:
27+
pool.type.toLowerCase() === 'concentrated'
28+
? `https://raydium.io/clmm/create-position/?pool_id=${pool.id}`
29+
: `https://raydium.io/liquidity/increase/?mode=add&pool_id=${pool.id}`,
30+
};
31+
});
32+
};
33+
34+
module.exports = { apy };

src/adaptors/resolv-rlp/index.js

Lines changed: 0 additions & 114 deletions
This file was deleted.
Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ const axios = require('axios');
33
const utils = require('../utils');
44
const ethers = require('ethers');
55

6+
// RLP Constants
7+
const RLP = '0x4956b52aE2fF65D74CA2d61207523288e4528f96';
8+
const rlpPriceStorage = '0xaE2364579D6cB4Bbd6695846C1D595cA9AF3574d';
9+
const topic0priceSet =
10+
'0x2f0fe01aa6daff1c7bb411a324bdebe55dc2cd1e0ff2fc504b7569346e7d7d5a';
11+
const priceSetInterface = new ethers.utils.Interface([
12+
'event PriceSet(bytes32 indexed key, uint256 price, uint256 timestamp);',
13+
]);
14+
15+
// stUSR Constants
616
const stUSR = '0x6c8984bc7DBBeDAf4F6b2FD766f16eBB7d10AAb4';
717
const USR = '0x66a1E37c9b0eAddca17d3662D6c05F4DECf3e110';
818
const rewardDistributor = '0xbE23BB6D817C08E7EC4Cd0adB0E23156189c1bA9';
9-
1019
const topic0rewardDistributed =
1120
'0x3863fc447b7dde3f3f5a5ca0b5b06a5fd3570963a1a29918f09036746293f658';
12-
1321
const rewardDistributedInterface = new ethers.utils.Interface([
1422
'event RewardDistributed(bytes32 indexed idempotencyKey, uint256 totalShares, uint256 totalUSRBefore, uint256 totalUSRAfter, uint256 stakingReward, uint256 feeReward)',
1523
]);
@@ -50,6 +58,62 @@ const calculateStUSRApy = (logDescription) => {
5058
return ((sharesRateAfter - sharesRateBefore) / sharesRateBefore) * 365;
5159
};
5260

61+
const rlpPool = async () => {
62+
try {
63+
const totalSupply = await getTotalSupply(RLP);
64+
const currentBlock = await sdk.api.util.getLatestBlock('ethereum');
65+
const currentDate = new Date(currentBlock.timestamp * 1000);
66+
const previousStartOfDay =
67+
new Date(currentDate).setHours(0, 0, 0, 0) - 2 * DAY_IN_MS;
68+
69+
const [fromBlock] = await utils.getBlocksByTime(
70+
[previousStartOfDay / 1000],
71+
'ethereum'
72+
);
73+
const toBlock = currentBlock.block;
74+
75+
const logs = (
76+
await sdk.api.util.getLogs({
77+
target: rlpPriceStorage,
78+
topic: '',
79+
fromBlock,
80+
toBlock,
81+
keys: [],
82+
chain: 'ethereum',
83+
topics: [topic0priceSet],
84+
})
85+
).output.sort((a, b) => a.blockNumber - b.blockNumber);
86+
87+
let aprBase = 0;
88+
if (logs.length >= 2) {
89+
const lastLpPrice = priceSetInterface.parseLog(logs[logs.length - 1]).args
90+
.price;
91+
const previousLpPrice = priceSetInterface.parseLog(logs[logs.length - 2])
92+
.args.price;
93+
94+
aprBase = ((lastLpPrice - previousLpPrice) / previousLpPrice) * 365;
95+
}
96+
97+
const price =
98+
logs.length > 0
99+
? priceSetInterface.parseLog(logs[logs.length - 1]).args.price / 1e18
100+
: await getTokenPrice(RLP);
101+
const tvl = totalSupply * price;
102+
103+
return {
104+
pool: RLP,
105+
symbol: 'RLP',
106+
chain: 'ethereum',
107+
project: 'resolv',
108+
tvlUsd: tvl,
109+
apyBase: aprBase * 100,
110+
};
111+
} catch (error) {
112+
console.error('Error fetching RLP pool data:', error);
113+
throw error;
114+
}
115+
};
116+
53117
const stUsrPool = async () => {
54118
try {
55119
const totalSupply = await getTotalSupply(stUSR);
@@ -91,7 +155,7 @@ const stUsrPool = async () => {
91155
pool: stUSR,
92156
symbol: 'stUSR',
93157
chain: 'ethereum',
94-
project: 'resolv-usr',
158+
project: 'resolv',
95159
tvlUsd: tvl,
96160
apyBase: aprBase * 100,
97161
};
@@ -103,7 +167,7 @@ const stUsrPool = async () => {
103167

104168
const apy = async () => {
105169
try {
106-
return [await stUsrPool()];
170+
return [await rlpPool(), await stUsrPool()];
107171
} catch (error) {
108172
console.error('Error fetching APYs:', error);
109173
throw error;

0 commit comments

Comments
 (0)