Skip to content

Commit ee50d64

Browse files
authored
Merge pull request #2189 from rocky-protocol/feat/add-rocky
Feat: add rocky
2 parents c4ad084 + fd04606 commit ee50d64

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

src/adaptors/rocky/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const config = {
2+
sei: {
3+
chainName: 'sei',
4+
USDr: '0x53fdd705873d8259d6d179901fc3fdcb5339f921',
5+
sUSDr: '0xc0029b98f09c9062056c14c0329d3a114a098617',
6+
},
7+
};
8+
9+
module.exports = { config };

src/adaptors/rocky/index.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const utils = require('../utils');
2+
const sdk = require('@defillama/sdk');
3+
const ethers = require('ethers');
4+
const { config } = require('./config');
5+
const BigNumber = require('bignumber.js');
6+
7+
// function getEstimatedAPR is misleading, it returns the estimated APY
8+
const getEstimatedAPR =
9+
'function estimatedAPR() external view returns (uint256)';
10+
const getTotalAssets = 'function totalAssets() external view returns (uint256)';
11+
12+
const getsUSDrData = async (chain, chainConfig) => {
13+
const { chainName, USDr, sUSDr } = chainConfig;
14+
let estimatedAPY;
15+
let totalAssets;
16+
const api = new sdk.ChainApi({ chain });
17+
[estimatedAPY, totalAssets] = await Promise.all([
18+
api.call({
19+
abi: getEstimatedAPR,
20+
target: sUSDr,
21+
}),
22+
api.call({
23+
abi: getTotalAssets,
24+
target: sUSDr,
25+
}),
26+
]);
27+
28+
const tvlUsd = new BigNumber(
29+
ethers.utils.formatUnits(totalAssets, 18)
30+
).toNumber();
31+
const apyBase = new BigNumber(
32+
ethers.utils.formatUnits(estimatedAPY, 16)
33+
).toNumber();
34+
35+
return {
36+
pool: `${sUSDr}-rocky`.toLowerCase(),
37+
chain: utils.formatChain(chainName),
38+
project: 'rocky',
39+
symbol: 'sUSDr',
40+
tvlUsd: tvlUsd,
41+
apyBase: apyBase,
42+
rewardTokens: [USDr],
43+
underlyingTokens: [USDr],
44+
poolMeta: 'saving',
45+
};
46+
};
47+
48+
const main = async () => {
49+
const markets = [];
50+
for (let [chain, data] of Object.entries(config)) {
51+
const result = await getsUSDrData(chain, data);
52+
markets.push(result);
53+
}
54+
return markets;
55+
};
56+
57+
module.exports = {
58+
timetravel: false,
59+
apy: main,
60+
url: 'https://app.rocky.cash/earn',
61+
};

0 commit comments

Comments
 (0)